Created
February 14, 2017 10:06
-
-
Save matklad/672c2fd23235b86949d721d51422be39 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trait Command { | |
fn cli(&self) -> clap::App; | |
fn execute(&self, config: &Config, args: &clap::Args); | |
} | |
trait WsCommand { | |
fn cli(&self) -> clap::App; | |
fn execute(&self, config: &Config, ws: &Workspace, args: &clap::Args); | |
} | |
impl<T: WsCommand> Command for T { | |
fn cli(&self) -> clap::App { | |
<T as WsCommand>::cli(self) | |
} | |
fn execute(&self, config: &Config, args: &clap::Args) { | |
let ws = configure_ws(config, args); | |
<T as WsCommand>::execute(self, config, ws, args) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment