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

New API for subcommands #24

Merged
merged 2 commits into from Mar 22, 2016

Conversation

Projects
None yet
2 participants
@White-Oak
Contributor

White-Oak commented Mar 22, 2016

As a need for subcommands to be run with vecs appeared(#23), I designed a pair of new traits:

  • AmethystArgs is a common trait for Clap-like arguments.
    It has two methods (value_of, is_present) and two implementations (for clap::ArgMatches and Vec<&str>). It is a common denominator to be used in Amethyst CLI and allows to abstractize from the details of implementation.
  • AmethystCmd is a trait that should be implemented in order to call something a subcommand.
    It has one method (fn execute<I: AmethystArgs>(matches: &I) -> cargo::CmdResult) which is an entry point to every subcommand. Thus, all subcommands are called via subcmnd_name::Cmd::execute(args).

This design, with little changes to existing code, allows to call executes both with vecs and clap-args.

PS: All subcommands are update to be used with AmethystCmd

@ebkalderon

This comment has been minimized.

Show comment
Hide comment
@ebkalderon

ebkalderon Mar 22, 2016

Member

Thanks, this looks pretty good. I'll merge it.

Member

ebkalderon commented Mar 22, 2016

Thanks, this looks pretty good. I'll merge it.

ebkalderon added a commit that referenced this pull request Mar 22, 2016

@ebkalderon ebkalderon merged commit faa800b into amethyst:master Mar 22, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment