Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI interface #14

Open
tgross35 opened this issue Sep 12, 2023 · 1 comment
Open

CLI interface #14

tgross35 opened this issue Sep 12, 2023 · 1 comment

Comments

@tgross35
Copy link
Contributor

Want to add a simple CLI interface that can do things like linting of libraries. Lint ideas:

  • Verify no duplicate pin numbers on device with same mode `no_duplicate
register_lint! {
    name: "Foobar Lint",
    requires: [SchLib, PcbLIb], // 
    
}

trait Lint {
    const ID: &'static str;
    const NAME: &'static str;
    const DESCRIPTION: &'static str;

    fn set_requires(&mut Vec<FileType>)  {
        
    }

    
    fn load_schlib(: &SchLib) {}
    fn load_pcblib(: &SchLib) {}
    fn load_schdoc: &SchLib) {}
    fn load_pcbdoc(: &SchLib) {}
}
#[derive(Args)]
#[clap(flatten)]
struct LintArgs {
    /// Mark these lints as allowed
    #[clap(short='A', long, value_delimiter = ',', num_args = 1..)]
    allow, Vec<String>,

    /// Emit an error on these lints but exit successfully
    #[clap(short='w', long, value_delimiter = ',', num_args = 1..)]
    warn, Vec<String>,

    /// Fail linting if these occur. `-D warnings` can be passed to deny
    /// everything that is usually a warning
    #[clap(short='D', long, value_delimiter = ',', num_args = 1..)]
    deny, Vec<String>,
}

enum LintLevel {
    Allow,
    Warn,
    Deny
}

fn x(cli: &mut Args) {
    let mut lints: BTreeMap<Lint, LintLevel> = generate_default_lints();
    if let Some(idx) = cli.deny.iter().position(|x| *x == "warnings") {
        cli.deny.remove(idx);
        // set all warnings to deny
    }

    for lint in cli.allow {
        // set lint to allow
    }
    for lint in cli.warn {
        // set lint to warn
    }
    for lint in cli.deny {
        // set lint to deny
    }
}

More general CLI thoughts:

# Validate a single schlib file
foo validate File.SchLib 
# Validate a 
foo validate --schlib randomfile --pchlib otherfile
# List all items in a file
foo list File.SchLib
@tgross35
Copy link
Contributor Author

tgross35 commented May 2, 2024

Lints should just be in rhai or something

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant