Skip to content

feat: add command aliases#2501

Merged
Codelax merged 22 commits intoscaleway:masterfrom
Codelax:command_aliases
Mar 6, 2023
Merged

feat: add command aliases#2501
Codelax merged 22 commits intoscaleway:masterfrom
Codelax:command_aliases

Conversation

@Codelax
Copy link
Copy Markdown
Member

@Codelax Codelax commented Sep 14, 2022

Close #947

Still need to fix completion when using an aliased namespace like scw k8s cl cre<TAB>

Ideas

  • Generate alias based on commands isc = instance server create, isl = instance server list
    It creates many duplicates, we could show different alternative on completion.
  • Complete alias into expanded commands scw isc<tab> ==> scw instance server create |
    Tricky to give multiple words in one suggestions depending on used shell (bash, zsh...)
  • Move config to a cli.yml file in a aliases field
  • Make commands easier to use

@Codelax Codelax self-assigned this Sep 22, 2022
@Codelax Codelax added this to the v2.7.0 milestone Sep 22, 2022
@Codelax Codelax marked this pull request as ready for review September 22, 2022 13:30
@Codelax Codelax marked this pull request as draft September 22, 2022 13:32
@Codelax Codelax marked this pull request as ready for review September 28, 2022 14:47
@Codelax Codelax changed the title feat(core): add command aliases feat: add command aliases Sep 28, 2022
Comment thread internal/alias/config.go Outdated
Comment thread internal/alias/config.go Outdated
Comment thread internal/alias/config.go
Comment thread internal/alias/config.go Outdated
Comment thread internal/core/context.go Outdated
Comment thread cmd/scw/testdata/test-all-usage-alias-usage.golden Outdated
@remyleone remyleone added the priority:medium Improvements that are not the main priority label Jan 25, 2023
@Codelax
Copy link
Copy Markdown
Member Author

Codelax commented Feb 17, 2023

  • scw alias alias create l resource=instance.server.list
  • scw alias alias create isl command.0=instance command.1=server command.2=list

move alias resource to config: scw config alias

@Codelax Codelax marked this pull request as draft February 20, 2023 09:17
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

Merging #2501 (84fb56c) into master (e0efde6) will decrease coverage by 0.32%.
The diff coverage is 49.44%.

@@            Coverage Diff             @@
##           master    #2501      +/-   ##
==========================================
- Coverage   75.15%   74.83%   -0.32%     
==========================================
  Files         134      142       +8     
  Lines       26080    28207    +2127     
==========================================
+ Hits        19600    21109    +1509     
- Misses       5810     6369     +559     
- Partials      670      729      +59     
Impacted Files Coverage Δ
internal/alias/list.go 0.00% <0.00%> (ø)
internal/alias/resource_alias.go 0.00% <0.00%> (ø)
internal/core/command.go 44.89% <0.00%> (-3.64%) ⬇️
internal/core/shell.go 10.32% <0.00%> (-0.18%) ⬇️
internal/core/validate.go 44.21% <0.00%> (-3.58%) ⬇️
internal/namespaces/autocomplete/autocomplete.go 11.14% <0.00%> (-0.19%) ⬇️
internal/namespaces/iam/v1alpha1/error.go 0.00% <0.00%> (ø)
internal/namespaces/instance/v1/custom.go 98.05% <ø> (-0.02%) ⬇️
...ernal/namespaces/instance/v1/custom_privatenics.go 88.46% <ø> (+4.67%) ⬆️
internal/namespaces/init/init.go 46.96% <35.92%> (-6.37%) ⬇️
... and 15 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@Codelax Codelax force-pushed the command_aliases branch 2 times, most recently from a2861b8 to a85b7e9 Compare March 3, 2023 16:04
@Codelax Codelax marked this pull request as ready for review March 3, 2023 16:04
Copy link
Copy Markdown
Contributor

@kindermoumoute kindermoumoute left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still think we should suggest to add some usefull aliases somewhere, maybe in scw init?

Comment thread docs/commands/alias.md
Comment thread internal/config/config.go Outdated
Comment thread internal/core/alias.go Outdated
Comment thread internal/core/autocomplete.go Outdated
Comment thread internal/core/testing.go
Comment thread go.mod Outdated
Comment thread internal/core/context.go Outdated
Comment thread internal/namespaces/alias/alias.go
remyleone
remyleone previously approved these changes Mar 6, 2023
Comment thread internal/core/context.go Outdated
@Codelax Codelax added this pull request to the merge queue Mar 6, 2023
Merged via the queue into scaleway:master with commit 429239f Mar 6, 2023
@Codelax Codelax deleted the command_aliases branch March 6, 2023 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autocomplete core enhancement priority:medium Improvements that are not the main priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for aliased command

5 participants