Update xflags

This commit is contained in:
Thom Chiovoloni 2021-11-28 16:55:24 -08:00
parent 0f314f4990
commit d4d2c50bff
3 changed files with 18 additions and 19 deletions

View File

@ -10,4 +10,4 @@ publish = false
anyhow = "1"
smoljson = "0.1"
xshell = "0.1"
xflags = "0.1"
xflags = "0.2"

View File

@ -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<Self> {
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<std::ffi::OsString>) -> xflags::Result<Self> {
let mut p = xflags::rt::Parser::new(args);
Self::_parse(&mut p)
Self::from_vec_(args)
}
}
// generated end

View File

@ -2,7 +2,7 @@ mod bindgen;
mod flags;
use anyhow::Result;
use flags::XtaskCmd;
use flags::*;
use std::path::{Path, PathBuf};
fn main() {