Comments (2)
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`.
from argh.
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,
}
from argh.
Related Issues (20)
- Allow subcommand flattening HOT 3
- Process line breaks in description HOT 5
- [Optimisation] Stop re-parsing of commands for default sub commands
- Feature Request: choices HOT 5
- add an attribute on option argument to let `from_str_fn` can return `Vec<T>` or `Option<T>` as-is HOT 7
- Is it possible to get a `TopLevelCommand`'s `FieldAttrs` with the current exposed API?
- positional arguments made on field with reserved named (ref_) keep the trailing _ in help text
- Negative switches
- Subcommand with no additional arguments? HOT 1
- Impossible to include angle brackets in help text in a way that satisfies argh and rustdoc
- Change `FromArgs::from_args` to accept `AsRef<str>`
- Support something like --helpfull which displays help for all subcommands HOT 2
- `#[argh(description = "...")]` only supports literal HOT 2
- Single dash is parsed as unrecognized argument HOT 1
- Disable automatically generated help message
- mutual exclusive options/switches
- don't work as a cargo-subcommand
- Any ability to specify 'raw' greedy args or pass-through?
- Consider making serde dependency optional (as a feature) HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from argh.