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

Subcommand aliases #281

Open
danielbayley opened this issue Jun 12, 2020 · 8 comments · May be fixed by #283
Open

Subcommand aliases #281

danielbayley opened this issue Jun 12, 2020 · 8 comments · May be fixed by #283

Comments

@danielbayley
Copy link
Contributor

danielbayley commented Jun 12, 2020

Is your feature request related to a problem? Please describe.
mas could use a few aliases, to bring it more in line with brew and cask

Describe the solution you'd like
These could include:

  • mas -v/--version -> mas version
  • mas -h/--help -> mas help
  • mas ls -> mas list
  • mas i -> mas install
  • mas rm -> mas uninstall
  • mas update -> brew upgrade mas
@phatblat
Copy link
Member

Good idea! These would be easy to add.

@danielbayley
Copy link
Contributor Author

These would be easy to add.

@phatblat I imagine so… although I haven't dug into Swift yet… If you point out where in the codebase, I can do a PR…

@phatblat
Copy link
Member

phatblat commented Jun 14, 2020

This project uses Commandant and all the commands live in the Commands folder. I don't see an option in Commandant for creating a command alias. However, you could:

  1. Duplicate the classes
  2. Add the new command class to the registry main.swift

danielbayley added a commit to danielbayley/mas that referenced this issue Jun 16, 2020
Add `i` alias for `install` command. See mas-cli#281.
danielbayley added a commit to danielbayley/mas that referenced this issue Jun 16, 2020
Add `ls` alias for `list` command. See mas-cli#281.
danielbayley added a commit to danielbayley/mas that referenced this issue Jun 16, 2020
Add `remove` alias for `uninstall` command. See mas-cli#281.
danielbayley added a commit to danielbayley/mas that referenced this issue Jun 16, 2020
Add `rm` alias for `uninstall` command. See mas-cli#281.
@danielbayley danielbayley linked a pull request Jun 16, 2020 that will close this issue
@danielbayley
Copy link
Contributor Author

danielbayley commented Jun 16, 2020

This project uses Commandant and all the commands live in the Commands folder. I don't see an option in Commandant for creating a command alias. However, you could:

  1. Duplicate the classes

  2. Add the new command class to the registry main.swift

@phatblat Ok, quickly done that for i, ls, rm/remove, and a rough implementation of update in #283… Not sure how to deal with -v/--version, or -h/--help within the context of the Commandant framework though?

danielbayley added a commit to danielbayley/mas that referenced this issue Jun 16, 2020
Add `update` alias for `brew upgrade mas`. See mas-cli#281.
@muescha
Copy link

muescha commented Jun 18, 2022

the -v/--version, or -h/--help are flags and options in the Commandant system

@muescha
Copy link

muescha commented Jun 20, 2022

just copy over the command looks not good as coding style - i would create a wrapper command for alias and wrap them in this command - so no duplicate code is created

see comment here: Carthage/Commandant#155 (comment)

if the alias command not goes into commandant - we can add it anyway into the mas codebase

Note: duplicate code is bad, because if someone change the code most time they forget to edit the "copied" code part)

@rgoldberg rgoldberg changed the title Aliases? Subcommand aliases Sep 15, 2024
@rgoldberg
Copy link
Contributor

@mas-cli/contributors Commandant is dormant, without updates for 4 years.

Apple now provides the open source Swift Argument Processor, which supports aliases and is actively being developed.

I imagine switching shouldn't be hard. Is it OK to switch?

Various other command line issues exist, like validating arguments, improving help messages, and generating bash, zsh, and fish completion scripts. It probably makes sense to switch over ASAP, so we don't do unnecessary work that will either need to be redone or that Swift Argument Parser can automatically do for us.

Does anyone disagree? Are there other better frameworks?

@rgoldberg
Copy link
Contributor

rgoldberg commented Sep 25, 2024

@mas-cli/admins

I've locally refactored mas to use SAP instead of Commandant.

To get everything working, I moved everything from MasKit into mas. Only the mas executable target still exists (it now produces an mas Swift module); the MasKit library target (& its associated Swift module) is gone. I had to update swift-tools-version from 5.3 to 5.5.

Is there any need to retain MasKit, given that I got testing to work without a separate library?

Is it OK to have upgraded swift-tools-version from 5.3 to 5.5?

I also had to remove swift-format from the dependencies because that forced an older version of Swift Argument Parser.

The code doesn't use swift-format; it is only used by the lint & the format scripts. I switched it to just running swift-format from the command line, which makes more sense. The dependency might have been to download different versions of swift-format for different Swift versions dictated by different macOS versions, but that should be handled by the brew swift-format formula, or by a tap if we need functionality outside of what the formula provides.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants