Repository navigation
Use man content for `help <cmd>' and '<cmd> --help' - #665
Conversation
|
Oops, 'go generate' is go 1.4+ so the 1.3 tests failed. We're dropping those though I hear :) |
Call 'go generate ./commands' to create string entries from .ronns which the cobra command can then use (added to the build scripts)
49c0222 to
e970264
Compare
There was a problem hiding this comment.
Don't print byte arrays :)
$ script/bootstrap
Using go1.3
go generate failed:
[103 111 58 32 117 110 107 110 111 119 110 32 115 117 98 99 111 109 109 97 110 100 32 34 103 101 110 101 114 97 116 101 34 10 82 117 110 32 39 103 111 32 104 101 108 112 39 32 102 111 114 32 117 115 97 103 101 46 10]exit status 1
|
I really dig this idea 👍 It's like #568, but takes advantage of go's code generation (which I've been meaning to check out since it was announced). Also, to answer your final reply on that thread:
Nope, that sounds awesome. Then the man page references at the bottom would actually link to each other 🤘 |
Gah, I was looking for that yesterday but couldn't find it, I must have been looking at the issues. I prefer the map approach & general help/usage functions too since it means it automatically works for new commands if you provide a man page, without having any compile errors. About the HTML on Windows; that's basically the other option; we could instead have 2 different behaviours for Linux/Mac and Windows, the former calling 'man git-lfs-foo' and the latter opening HTML which we have to deploy somewhere. My main problem with that approach is that even though it's nice in a pre-packaged release, it's not very usable in source builds, because the man/HTML might not be present (or at the least the paths would be different) I'm tempted just to go with this for now (with suitable reformatting) & consider extending things later so that when built with the release flags the man/HTML route is used instead. |
* Strips leader and footer which were just clutter * Reformats headers & removes unnecessary ones * Indents paragraphs following bullets Still TODO: reformat links
|
Already looking better, just want to tackle the links next: steve@Stevens-MacBook-Pro ~/p/G/s/g/g/git-lfs> git lfs help push
git lfs push [options] <remote> [<ref>...]<br>
git lfs push <remote> [<ref>...]<br>
git lfs push --object-id <remote> [<oid>...]
Upload Git LFS files to the configured endpoint for the current Git remote. By
default, it filters out objects that are already referenced by the local clone
of the remote.
Options:
* --dry-run:
Print the files that would be pushed, without actually pushing them.
* --all:
This pushes all objects to the remote that are referenced by any commit
reachable from the refs provided as arguments. If no refs are provided, then
all refs are pushed.
* --object-id:
This pushes only the object OIDs listed at the end of the command, separated
by spaces.
* --stdin:
Read the remote and branch on stdin. This is used in conjunction with the
pre-push hook and must be in the format used by the pre-push hook:
<local-ref> <local-sha1> <remote-ref> <remote-sha1>. If --stdin is used
the command line arguments are ignored. NOTE: This is deprecated in favor
of the pre-push command. |
Baby steps. 👍
That looks much better than what I saw. The man page headers were annoying. I like the more compact format. |
|
OK I think this is ready to be merged now. I've made the links look nicer: It's not 100% foolproof because it only processes the man pages line-wise and not with a full lexer (links split across lines wouldn't work for example) but I think it does the job much better for now. |
Particularly 'git lfs help'
I think any edge cases for the parser should be tested. I'm not sure how that would work yet though. |
Use man content for `help <cmd>' and '<cmd> --help'
Call 'go generate ./commands' to generate code from .ronn files which the cobra command can then use. Added to the build scripts but needs to be done manually at least once to test it outside that.
I've done the minimum re-formatting for now. The man format is pretty damn ugly on the command line and I'd like to do better but didn't want to spend time on that until the principle was approved. For now it just fixes the backtick issue, other things we could do:
command --help(just contents of SYNOPSIS, DESCRIPTION and OPTIONS) and only print the full text forhelp command. Cobra splits this as Usage/Help, currently it's the same for both.If you think this is a good idea I can hack on it some more.