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

Bash completion for flags #312

Merged
merged 8 commits into from
Jun 14, 2022
Merged

Conversation

mabelzhang
Copy link
Contributor

@mabelzhang mabelzhang commented May 20, 2022

🎉 New feature

Part of gazebosim/gz-tools#1
Used together with gazebosim/gz-tools#87

Summary

Bash completion, installation, tests.

Small corner cutting for easier forward-porting:
ign service has --help-all in Fortress+
ign topic has --json-output in Fortress+
This PR targets Citadel, but I've removed those so that the tests don't fail when this is forward-ported to Fortress 😅 We could add a PR to add these back to Citadel - they'd need to be added to both the bash script and the tests. They don't seem like critical flags to be in tab completion, and if a user types --help, they can still see them.

Alternatively, I can add the Citadel-specific flags in this PR, and add a comment to remove them in Fortress?
Update: For correctness, I've gone ahead and do that in 7ccc7a6.

Test it

This works with the installation method in the gz-tools PR described in this comment gazebosim/gz-tools#87 (comment) .

$ . install/share/gz/gz.completion

$ ign service -<tab>
--force-version  --req            --versions       -s
--help           --reqtype        -h               -v
--info           --service        -i               
--list           --timeout        -l               
--reptype        --version        -r               

$ ign topic -<tab>
--duration       --msgtype        -d               -n
--echo           --num            -e               -p
--force-version  --pub            -h               -t
--help           --topic          -i               -v
--info           --version        -l               
--list           --versions       -m            

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

Signed-off-by: Mabel Zhang <[email protected]>
@mabelzhang mabelzhang added the OOBE 📦✨ Out-of-box experience label May 20, 2022
@mabelzhang mabelzhang requested a review from chapulina May 20, 2022 03:28
@mabelzhang mabelzhang requested a review from caguero as a code owner May 20, 2022 03:28
@mabelzhang mabelzhang added this to Inbox in Core development via automation May 20, 2022
@github-actions github-actions bot added Gazebo 1️1️ Dependency of Gazebo classic version 11 🏰 citadel Ignition Citadel labels May 20, 2022
@mabelzhang mabelzhang moved this from Inbox to In review in Core development May 20, 2022
@codecov
Copy link

codecov bot commented May 20, 2022

Codecov Report

❗ No coverage uploaded for pull request base (ign-transport8@788905f). Click here to learn what that means.
The diff coverage is n/a.

@@                Coverage Diff                @@
##             ign-transport8     #312   +/-   ##
=================================================
  Coverage                  ?   83.81%           
=================================================
  Files                     ?       51           
  Lines                     ?     5035           
  Branches                  ?        0           
=================================================
  Hits                      ?     4220           
  Misses                    ?      815           
  Partials                  ?        0           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 788905f...b6c5430. Read the comment docs.

@mabelzhang
Copy link
Contributor Author

mabelzhang commented May 21, 2022

Just realized there's also the log command. That's a bit different from the rest, as it has a third level of subcommands, ign log record|playback -<flag>. It needs another level of logic in the bash script, similar to ign-tools/etc/ign.bash_completion.sh.

😅 That logic would go where I say in the comments

because we never have two
    # subcommands in the same line. If that is ever needed, change here to
    # detect subsequent subcommands

In the interest of time, I think I will try to cover the two-level flags for as many libraries as possible, for commands like ign <subcommand> -<flag>.

When we have more time, we can come back to the three-level flags, like ign <subcommand> <subsubcommand> -<flag>. So far, I can see that applies to ign log and ign fuel. There may be others.

@chapulina chapulina added the needs upstream release Blocked by a release of an upstream library label May 23, 2022
@chapulina chapulina requested a review from ahcorde May 23, 2022 16:57
src/cmd/transport.bash_completion.sh Show resolved Hide resolved
src/cmd/transport.bash_completion.sh Outdated Show resolved Hide resolved
src/cmd/transport.bash_completion.sh Outdated Show resolved Hide resolved
src/ign_TEST.cc Outdated Show resolved Hide resolved
src/ign_TEST.cc Outdated Show resolved Hide resolved
src/ign_TEST.cc Outdated Show resolved Hide resolved
Signed-off-by: Mabel Zhang <[email protected]>
Signed-off-by: Mabel Zhang <[email protected]>
src/cmd/CMakeLists.txt Outdated Show resolved Hide resolved
Signed-off-by: Mabel Zhang <[email protected]>
Signed-off-by: Louise Poubel <[email protected]>
Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

Pushed some changes on b6c5430:

@chapulina chapulina merged commit 30da9d3 into ign-transport8 Jun 14, 2022
@chapulina chapulina deleted the mabelzhang/tab_completion branch June 14, 2022 23:34
Core development automation moved this from In review to Done Jun 14, 2022
@chapulina chapulina removed the needs upstream release Blocked by a release of an upstream library label Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏰 citadel Ignition Citadel Gazebo 1️1️ Dependency of Gazebo classic version 11 OOBE 📦✨ Out-of-box experience
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

None yet

3 participants