Skip to content

Use man content for `help <cmd>' and '<cmd> --help' - #665

Merged
technoweenie merged 6 commits into
git-lfs:masterfrom
sinbad:help-from-man
Sep 17, 2015
Merged

technoweenie merged 6 commits into
git-lfs:masterfrom
sinbad:help-from-man

Conversation

@sinbad

@sinbad sinbad commented Sep 14, 2015

Copy link
Copy Markdown
Contributor

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:

  • Strip off the 2-line headers
  • Strip 'SYNOPSIS' and pull out the command summary as the first line
  • Strip '##' section markers generally
  • Use an abbreviated form for command --help (just contents of SYNOPSIS, DESCRIPTION and OPTIONS) and only print the full text for help 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.

@sinbad sinbad mentioned this pull request Sep 14, 2015
6 tasks done
@sinbad

sinbad commented Sep 14, 2015

Copy link
Copy Markdown
Contributor Author

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)
Comment thread script/build.go Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Doh.

@technoweenie

Copy link
Copy Markdown
Contributor

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:

were you aware that the default behaviour in Windows for something like git checkout --help is that it launches the browser & displays the HTML version of the man page?

Nope, that sounds awesome. Then the man page references at the bottom would actually link to each other 🤘

@sinbad

sinbad commented Sep 15, 2015

Copy link
Copy Markdown
Contributor Author

I really dig this idea 👍 It's like #568

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
@sinbad

sinbad commented Sep 15, 2015

Copy link
Copy Markdown
Contributor Author

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.

@technoweenie

Copy link
Copy Markdown
Contributor

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.

Baby steps. 👍

Already looking better, just want to tackle the links next

That looks much better than what I saw. The man page headers were annoying. I like the more compact format.

@sinbad

sinbad commented Sep 17, 2015

Copy link
Copy Markdown
Contributor Author

OK I think this is ready to be merged now. I've made the links look nicer:

Options:

* -I <paths> --include=<paths>:
  Specify lfs.fetchinclude just for this invocation; see "Include and exclude"

* -X <paths> --exclude=<paths>:
  Specify lfs.fetchexclude just for this invocation; see "Include and exclude"

* --recent:
  Download objects referenced by recent branches & commits in addition to those
  that would otherwise be downloaded. See "Recent changes"

* --all:
  Download all objects referenced by any commit that is reachable; this is
  primarily for backup / migration purposes. Cannot be combined with --recent or
  --include/--exclude. Ignores any globally configured include and exclude paths
  to ensure that all objects are downloaded.

Include and exclude
-------------------

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.

@technoweenie

Copy link
Copy Markdown
Contributor

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.

I think any edge cases for the parser should be tested. I'm not sure how that would work yet though.

technoweenie added a commit that referenced this pull request Sep 17, 2015
Use man content for `help <cmd>' and '<cmd> --help'
@technoweenie
technoweenie merged commit 53bcb75 into git-lfs:master Sep 17, 2015
@sinbad
sinbad deleted the help-from-man branch September 18, 2015 09:05
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.

2 participants