From d4d2c50bff360262b7519d5806f4a5ed5cdf929b Mon Sep 17 00:00:00 2001 From: Thom Chiovoloni Date: Sun, 28 Nov 2021 16:55:24 -0800 Subject: [PATCH] Update xflags --- xtask/Cargo.toml | 2 +- xtask/src/flags.rs | 33 ++++++++++++++++----------------- xtask/src/main.rs | 2 +- 3 files changed, 18 insertions(+), 19 deletions(-) diff --git a/xtask/Cargo.toml b/xtask/Cargo.toml index 638d1d9..355e524 100644 --- a/xtask/Cargo.toml +++ b/xtask/Cargo.toml @@ -10,4 +10,4 @@ publish = false anyhow = "1" smoljson = "0.1" xshell = "0.1" -xflags = "0.1" +xflags = "0.2" diff --git a/xtask/src/flags.rs b/xtask/src/flags.rs index f0643af..bbdb803 100644 --- a/xtask/src/flags.rs +++ b/xtask/src/flags.rs @@ -3,18 +3,17 @@ //! //! When you modify stuff in the args_parser block, you'll get compile errors. //! to fix these: -//! 1. run `env XFLAGS_DUMP= cargo build` in the shell. -//! 2. this will error, but should spit out a block of code delimited by -//! "generated start" and "generated end" comments. (if not, you probably -//! have an error message about your usage of the macro, fix and retry) -//! 3. Copy the generated code, and replace the bottom of this file with it. -//! -//! Also, rust-analyzer says this file has a "unresolved macro call". I don't -//! know why, just ignore it — it goes away if you close this file. +//! 1. run `env UPDATE_XFLAGS=1 cargo build -p xtask` in the shell. +//! 2. this will error, but should update the contents of this file that exists +//! between `// generated start` and `// generated end`. +//! 3. If it has trouble updating, try deleting everything from this file that +//! isn't part of the `xflags!` macro (all the generated code), or ping me +//! (@thomcc). #![allow(dead_code)] -xflags::args_parser! { +xflags::xflags! { + src "./src/flags.rs" /// Run custom build command. cmd xtask { optional -v, --verbose @@ -41,7 +40,7 @@ xflags::args_parser! { // generated start // The following code is generated by `xflags` macro. -// Run `env XFLAGS_DUMP= cargo build` to regenerate. +// Run `env UPDATE_XFLAGS=1 cargo build` to regenerate. #[derive(Debug)] pub struct Xtask { pub verbose: bool, @@ -62,10 +61,10 @@ pub struct Help { } #[derive(Debug)] -pub struct Lint {} +pub struct Lint; #[derive(Debug)] -pub struct Test {} +pub struct Test; #[derive(Debug)] pub struct Bindgen { @@ -75,16 +74,16 @@ pub struct Bindgen { } impl Xtask { - pub const HELP: &'static str = Self::_HELP; + pub const HELP: &'static str = Self::HELP_; + #[allow(dead_code)] pub fn from_env() -> xflags::Result { - let mut p = xflags::rt::Parser::new_from_env(); - Self::_parse(&mut p) + Self::from_env_() } + #[allow(dead_code)] pub fn from_vec(args: Vec) -> xflags::Result { - let mut p = xflags::rt::Parser::new(args); - Self::_parse(&mut p) + Self::from_vec_(args) } } // generated end diff --git a/xtask/src/main.rs b/xtask/src/main.rs index 98e84ea..34f9fba 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -2,7 +2,7 @@ mod bindgen; mod flags; use anyhow::Result; -use flags::XtaskCmd; +use flags::*; use std::path::{Path, PathBuf}; fn main() {