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

daml-assistant: Install bash completion scripts on Linux and Mac. #3946

Merged
merged 10 commits into from
Jan 6, 2020

Conversation

ghost
Copy link

@ghost ghost commented Jan 3, 2020

This PR implements bash completion for the daml assistant. Most of this was already available out of the box via optparse-applicative's --bash-completion-script command, so this PR is mostly just concerned with installing that script in a standard location, if possible.

The command-line completion knows all the commands, and knows all the options for built-in commands (like daml version and daml install), but it cannot give any information for commands that are distributed with the SDK (like daml damlc or daml sandbox) because it doesn't know anything about their arguments. But at least the completion still tells you which commands are available.

Fixes #3875 for bash at least.

@ghost ghost requested a review from hurryabit as a code owner January 3, 2020 16:25
@ghost ghost changed the title Install bash completion scripts on Linux and Mac. daml-assistant: Install bash completion scripts on Linux and Mac. Jan 3, 2020
Copy link
Contributor

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

The changes look good to me but afaict you need to be root for this to actually work and I would like to not encourage that people install the SDK as root. Is there some directory where we can place these files without being root? E.g., place it in ~/.daml and then source it from ~/.bash_completion?

@ghost
Copy link
Author

ghost commented Jan 3, 2020

The changes look good to me but afaict you need to be root for this to actually work and I would like to not encourage that people install the SDK as root. Is there some directory where we can place these files without being root? E.g., place it in ~/.daml and then source it from ~/.bash_completion?

This was my first thought, but it doesn't seem too nice if the user removes daml forcibly and their custom completion rules stop working suddenly

@cocreature
Copy link
Contributor

Maybe we can only source it if it exists? Then removing ~/.daml will only leave a redundant line in ~/.bash_completion but not break anything.

@ghost
Copy link
Author

ghost commented Jan 3, 2020

Maybe we can only source it if it exists? Then removing ~/.daml will only leave a redundant line in ~/.bash_completion but not break anything.

Ah, of course! That's a great idea!

@ghost
Copy link
Author

ghost commented Jan 3, 2020

@cocreature I changed it as you suggested.

Copy link
Contributor

@cocreature cocreature left a comment

Choose a reason for hiding this comment

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

Looks great, thanks a lot!

@ghost ghost added the automerge label Jan 3, 2020
@stefanobaghino-da
Copy link
Contributor

Awesome, thanks!

I would suggest to add a line to the changelog to let users know of this (./unreleased.sh master.. has an empty output on this branch).

It's probably fine to let users find out on their own, but perhaps you may want to add a line somewhere in the docs to make users aware that, if they use bash, they have access to completions.

@ghost ghost removed the automerge label Jan 6, 2020
CHANGELOG_BEGIN

- [DAML Assistant] Bash completions for the DAML assistant are now
available via ``daml install``. These will be installed automatically
on Linux and Mac. If you use bash and have bash completions installed,
these bash completions let you use the tab key to autocomplete
many DAML Assistant commands, such as ``daml install`` and
``daml version``.

CHANGELOG_END
@ghost
Copy link
Author

ghost commented Jan 6, 2020

Awesome, thanks!

I would suggest to add a line to the changelog to let users know of this (./unreleased.sh master.. has an empty output on this branch).

It's probably fine to let users find out on their own, but perhaps you may want to add a line somewhere in the docs to make users aware that, if they use bash, they have access to completions.

Thanks for the suggestion, will do!

@ghost ghost requested review from bame-da and nemanja-da as code owners January 6, 2020 11:57
@ghost ghost added the automerge label Jan 6, 2020
@cocreature
Copy link
Contributor

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 1 pipeline(s).

@mergify mergify bot merged commit e055ad8 into master Jan 6, 2020
@mergify mergify bot deleted the bash-completions branch January 6, 2020 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Command line auto-completion for daml
4 participants