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

how skip a field like #[serde(skip)] #145

Open
cn-kali-team opened this issue Oct 10, 2022 · 2 comments
Open

how skip a field like #[serde(skip)] #145

cn-kali-team opened this issue Oct 10, 2022 · 2 comments

Comments

@cn-kali-team
Copy link

how skip a field like #[serde(skip)]

@erickt
Copy link
Collaborator

erickt commented Oct 12, 2022

If I’m understanding you correctly, you should be able to define an option field with an option type, with something like this:

    #[derive(FromArgs, PartialEq, Debug)]
    /// Reach new heights.
    struct GoUp<S: FromStr>
    where
        <S as FromStr>::Err: Display,
    {
        /// an optional nickname for the pilot
        #[argh(option)]
        pilot_nickname: Option<S>,
    }
    ```

if nothing is passed in for —pilot-nickname then it will be `None`. 

@cn-kali-team
Copy link
Author

Are there plans to add macros similar to those in like serde #[argh(skip)]

#[derive(Debug, Serialize, Deserialize, Clone, FromArgs, Default)]
#[argh(description = "observer_ward")]
pub struct ObserverWardConfig {
    #[serde(default)]
    #[argh(skip)]
    pub targets: Vec<String>,
    /// the target (required, unless --stdin used)
    #[argh(option, short = 't')]
    pub target: Option<String>,
    /// read target(s) from STDIN
    #[argh(switch)]
    #[serde(skip)]
    pub stdin: bool,
    /// validate the specified yaml file or grep keyword
    #[argh(option)]
    #[serde(skip)]
    pub verify: Option<String>,
    /// read the target from the file
    #[argh(option, short = 'f')]
    #[serde(skip)]
    pub file: Option<String>,
    /// update web fingerprint
    #[argh(switch, short = 'u')]
    #[serde(default)]
    pub update_fingerprint: bool,
    /// export to the csv file or Import form the csv file
    #[argh(option, short = 'c')]
    #[serde(skip)]
    pub csv: Option<String>,
    /// export to the json file or Import form the json file
    #[argh(option, short = 'j')]
    #[serde(skip)]
    pub json: Option<String>,
    /// proxy to use for requests (ex:[http(s)|socks5(h)]://host:port)
    #[argh(option)]
    #[serde(default)]
    pub proxy: Option<String>,
    /// set request timeout.
    #[argh(option, default = "default_timeout()")]
    #[serde(default = "default_timeout")]
    pub timeout: u64,
    /// the 'plugins' directory is used when the parameter is the default
    #[argh(option)]
    #[serde(default)]
    pub plugins: Option<String>,
    /// update nuclei plugins
    #[argh(switch)]
    #[serde(default)]
    pub update_plugins: bool,
    /// an optional nickname for the pilot
    #[argh(switch)]
    #[serde(skip)]
    pub update_self: bool,
    /// number of concurrent threads.
    #[argh(option, default = "default_thread()")]
    #[serde(default = "default_thread")]
    pub thread: u32,
    /// send results to webhook server (ex:https://host:port/webhook)
    #[argh(option)]
    #[serde(default)]
    pub webhook: Option<String>,
    /// using nmap fingerprint identification service (slow)
    #[argh(switch)]
    #[serde(default)]
    pub service: bool,
    /// start a web API service (ex:127.0.0.1:8080)
    #[argh(option, short = 's')]
    #[serde(skip)]
    pub api_server: Option<String>,
    /// api Bearer authentication
    #[argh(option, default = "default_token()")]
    #[serde(skip)]
    pub token: String,
    /// api background service
    #[argh(switch)]
    #[serde(skip)]
    pub daemon: bool,
    /// an optional nickname for the pilot
    #[argh(switch)]
    #[serde(skip)]
    pub silent: bool,
    /// filter mode,Display only the fingerprint that is not empty
    #[argh(switch)]
    #[serde(skip)]
    pub filter: bool,
}

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

2 participants