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

zsh completion for tarsnap 1.0.37 #226

Closed
wants to merge 5 commits into from
Closed

Conversation

vapniks
Copy link
Contributor

@vapniks vapniks commented Jan 2, 2017

archive names may optionally be completed by setting the archivefile variable at the top of the file

archive names may optionally be completed by setting the `archivefile` variable at the top of the file
@@ -0,0 +1,163 @@
#compdef tarsnap

# zsh completion function for tarsnap 1.0.37
Copy link
Member

Choose a reason for hiding this comment

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

Could you add some hint for zsh users as to how they'd use this file? i.e. should it be copied into /usr/share/zsh/completion/ , or /etc/zsh/, or $HOME/.zsh/ ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -0,0 +1,163 @@
#compdef tarsnap
Copy link
Member

Choose a reason for hiding this comment

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

Could this file be put into misc/zsh_completion/_tarsnap ? Or some other filename, but definitely within misc/ and beginning with zsh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll leave that to you :)

_tarsnap Outdated

# Set the following variable to the path of a file containing the output from "tarsnap --list-archives"
# i.e. one archive name per line. If left blank then archive names will not be completed.
local archivefile=
Copy link
Member

Choose a reason for hiding this comment

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

A little nitpicky, but could this variable be renamed to something like archivelist_file ? (or something similar, if underscores aren't allowed in zsh)
My first impression was that this was supposed to be a list of archives; I had to read the comment twice before I understood that it was supposed to point to a text file which contains a list of archive names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Also add note about where to store _tarsnap
@gperciva
Copy link
Member

Hmm, if I enter zsh and type:

% tarsnap --hu[TAB]

(trying to get --humanize-numbers), it turns into

% tarsnap --nuke

Does zsh autocompletion work very differently than bash's? I also tried

% tarsnap -c --hu[TAB]

and couldn't get it to complete --humanize-numbers (or --dry-run) in there.

@vapniks
Copy link
Contributor Author

vapniks commented Jan 14, 2017

That's because I used the SYNOPSIS in the man page for tarsnap as a guide. The --humanize-numbers option is only available for the -c, -d, -t and -x commands, after --keyfile, --cachdir, and -f have been specified.

@gperciva
Copy link
Member

gperciva commented Jan 16, 2017

Hmm, I see what you mean; the SYNOPSIS might be a bit misleading. Far below, in the EXAMPLES section, it states

Note that the --keyfile and --cachedir options can be specified via the
tarsnap.conf(5) configuration file, in which case they may be omitted
from the command line.

In addition, the -f option can be mixed in with the other [options]. It can even be omitted if --dry-run is specified.

Yes, I definitely think that the man page is misleading. I'll revise it and discuss with @cperciva.

@vapniks
Copy link
Contributor Author

vapniks commented Jan 16, 2017

I did make --keyfile and --cachedir optional, but -f is currently required. I could easily change this though.

@gperciva
Copy link
Member

-f is not actually mutually exclusive with --dry-run; there's nothing wrong with doing

tarsnap --humanize-numbers -f foo --dry-run -c --print-stats ~/backup

I'm still concerned about not being able to put options in whatever order I want. Again, writing

tarsnap --hu[TAB]

comes up with tarsnap --nuke, which is not at all what I was typing! I wonder if the auto-correct script is trying to be "too smart".

@vapniks
Copy link
Contributor Author

vapniks commented Jan 17, 2017

It's because it needs to see a mode option first. I can easily change it so that the order doesn't matter, but personally I prefer it that way since it makes it easier for me to remember the modes and important options (there are a lot of options that I will probably never use).

@vapniks
Copy link
Contributor Author

vapniks commented Jan 17, 2017

Actually, just realised that the first option needs to be a mode so that it knows what other options to offer (unless you don't mind all options being available for all modes).

@cperciva
Copy link
Member

cperciva commented Jun 3, 2020

@gperciva Is there a reason this is still open? I don't know if this was included in other changes.

@gperciva
Copy link
Member

gperciva commented Jun 3, 2020

There's kind-of a reason. I have a branch which parses the man page and automatically adds args to the bash completion file (which prompted the recent #403 and #404). I'm now working on extending that to cover the zsh completion file. (Although I think I'll just have it give a warning, rather than attempting to automatically edit the file, since the zsh one also includes short doc strings.)

I do hope to resolve this within a couple of PRs.

gperciva pushed a commit that referenced this pull request Jan 20, 2022
(Note from the committer.)
These were extracted from the zsh completion file proposed by vapniks in:
    #226
This was referenced Jan 20, 2022
gperciva pushed a commit that referenced this pull request Jan 21, 2022
(Note from the committer.)
These were extracted from the zsh completion file proposed by vapniks in:
    #226
@gperciva
Copy link
Member

Hi @vapniks,

We now have a zsh completion file for tarsnap, added in #518. It's generated automatically from our man-page, so it should always be up-to-date.

I'm terribly sorry about the 5-year delay. This rarely made it to the top of my todo list, and I'm not very familiar with zsh so it took a while until I was happy with a solution.

I used your descriptions of options in this PR and rewrote them into 086c670. Thank you for your contribution! And sorry again for the delay.

@gperciva gperciva closed this Jan 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants