Skip to content

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

Description

@cn-kali-team

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

Activity

  1. erickt commented on Oct 12, 2022

    @erickt
    Collaborator

    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`. 
  2. cn-kali-team commented on Oct 13, 2022

    @cn-kali-team
    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,
    }
  3. the-wondersmith commented on Sep 1, 2026

    @the-wondersmith

    @cn-kali-team Just submitted a PR that implements exactly this (#[argh(skip)] or #[argh(skip, default = "...")]) 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions