Skip to content
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

Add a fallback to alternate shards commands #202

Merged
merged 5 commits into from
Dec 7, 2020

Conversation

Willamin
Copy link
Contributor

This allows additional functionality to be added to the shards command in a similar way extra commands are added to git. Basically, if the shards command isn't found in shards itself, it will run shards-#{command}, passing STDIO through. If there is no executable that matches the attempted command, the regular shards usage message is shown.

@ysbaddaden
Copy link
Contributor

Any use cases?

@Willamin
Copy link
Contributor Author

Willamin commented Apr 25, 2018

In short, extensibility.

Sometimes subcommands don't belong in the core shards project, but would be nice to have and run under the same shards umbrella. This allows the community to create and maintain subcommands without needing approval from the maintainers of shards itself.

For example, rust has implemented a similar scheme in cargo (https://github.com/rust-lang/cargo/wiki/Third-party-cargo-subcommands). Some good subcommand examples from this list include:

  • audit (Audit lockfile for packages with security vulnerabilities)
  • graph (Build GraphViz DOT files of dependency graphs)

Additionally, I would argue that any of these are valid use cases:

@RX14
Copy link
Contributor

RX14 commented Apr 26, 2018

I'm not all too sure of this. If your tool is separate from shards why not give it a separate command instead of stuffing it under the shards command? I imagine it's just confusing to users what's part of shards and what is not.

@ysbaddaden
Copy link
Contributor

ysbaddaden commented Apr 26, 2018

Well, git provides this and I don't think there are much confusion.

That being said shards-x and shards x are just one letter apart, and otherwise strictly equivalent —except that the latter may eat up some arguments...

@Willamin
Copy link
Contributor Author

This PR's implementation should allow seamless passthrough of arguments.

@straight-shoota
Copy link
Member

straight-shoota commented Apr 26, 2018

The benefit of having shards x vs shards-x is that it can be used to develop features individually and later adopt them into shards without changing the invocation.

@ysbaddaden
Copy link
Contributor

I'll consider this for post v0.8.0 release.

@Sija
Copy link
Contributor

Sija commented Aug 31, 2018

We're already post v0.8.0, just a reminder ;)

@ysbaddaden ysbaddaden added this to the v1.0.0 milestone Feb 9, 2019
src/cli.cr Outdated Show resolved Hide resolved
src/cli.cr Outdated Show resolved Hide resolved
@z64 z64 mentioned this pull request Dec 31, 2019
@Sija
Copy link
Contributor

Sija commented Jan 1, 2020

@Willamin Are you willing to continue working on this PR?

@Willamin
Copy link
Contributor Author

@Sija Yes, sorry for the delay, I'll implement the suggestions from @straight-shoota. 😄

src/cli.cr Outdated Show resolved Hide resolved
@RX14
Copy link
Contributor

RX14 commented Jun 1, 2020

I've never actually seen a git-foo executable not included in the standard git. Is this feature actually used there?

@jhass
Copy link
Member

jhass commented Jun 1, 2020

yeah. Two good examples are https://github.com/tummychow/git-absorb and http://hg-git.github.io/ https://github.com/cosmin/git-hg. If you want you can also count https://github.com/github/hub, which is supposed to be aliased to git and adds new subcommands.

@straight-shoota
Copy link
Member

And a big collection of extra commands: https://github.com/tj/git-extras

src/cli.cr Outdated Show resolved Hide resolved
Willamin and others added 4 commits October 1, 2020 12:36
Shards will attempt to exec 'shards-#{subcommand}' if the
subcommand doesn't exist in core shards. If no executable exists
in the user's path, shards will fall back to 'shards help'.
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
src/cli.cr Outdated Show resolved Hide resolved
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
@straight-shoota straight-shoota merged commit b8ec9de into crystal-lang:master Dec 7, 2020
@straight-shoota
Copy link
Member

Thank you @Willamin

@Willamin Willamin deleted the feature/fallback branch December 7, 2020 19:50
f-fr pushed a commit to f-fr/shards that referenced this pull request Jan 2, 2021
Co-authored-by: Sijawusz Pur Rahnama <sija@sija.pl>
@bcardiff bcardiff modified the milestones: v1.0.0, v0.13.0 Jan 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants