[−][src]Trait dsa::Action
A command line action providing usage and call functionality.
The usage()
method returns the clap definition of a command line subcommand.
The call function is then to be called with the corresponding ArgMatches and the Hero to act on, returning a Result of an arbitrary list of Outputs.
Required methods
fn usage<'a, 'b>(&'a self) -> App<'b, 'b>
Command line argument definition of the subcommand of the action.
This App determines determines the ArgMatches of the call()
method.
fn call(&mut self, hero: &Hero, matches: &ArgMatches) -> Result<Vec<Output>>
A method which maps self, as well as the current Hero and the result of the usage()
-invocation into zero or more Outputs.
Implementors
impl Action for Cli
[src]
Boots up a cli interface with trackers holding mutable state.
fn usage<'a, 'b>(&'a self) -> App<'b, 'b>
[src]
fn call(&mut self, hero: &Hero, _: &ArgMatches) -> Result<Vec<Output>>
[src]
impl Action for Dump
[src]
fn usage<'a, 'b>(&'a self) -> App<'b, 'b>
[src]
fn call(&mut self, hero: &Hero, _: &ArgMatches) -> Result<Vec<Output>>
[src]
impl Action for Roll
[src]
Rolls the dice for a certain skill of the Hero, supports modifiers.
Examples
let mut roll = Roll::new_action(); hero.qualities.extend( vec![ (Agility,1), (Dexterity,2), (Strength,3), ] ); hero.skills.insert("bogen".to_string(),(4,[Agility,Dexterity,Strength])); let matches = roll.usage().get_matches_from(&["roll","-m","-5","--mod","3","bogen"]); let output = roll.call(&hero,&matches).unwrap(); assert_eq!(1,output.len()); if let Output::Roll { base, stat, mods, .. } = &output[0] { assert_eq!(4, *base); assert_eq!(&[1,2,3], stat); assert_eq!(-2, *mods); }