git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <stefanbeller@googlemail.com>
To: tr@thomasrast.ch, mhagger@alum.mit.edu, git@vger.kernel.org
Cc: Stefan Beller <stefanbeller@googlemail.com>
Subject: [PATCH] Documentation: add a script to generate a (long/short) options overview
Date: Fri,  1 Nov 2013 00:04:42 +0100	[thread overview]
Message-ID: <1383260682-12364-1-git-send-email-stefanbeller@googlemail.com> (raw)
In-Reply-To: <5272E1B9.6000705@googlemail.com>

Recently a discussion started on the mailing list, which short option
shall be best for a long option. (-f being always --force and therefore
should not be reassigned another meaning in one particular command)
See http://www.mail-archive.com/git@vger.kernel.org/msg38456.html

For discussions as these we need a script to easily generate an
overview of all available one letter options, and their long option
equivalents.

As the list of options was not retrieved fully automated,
there might be minor errors or missing items.

Signed-off-by: Stefan Beller <stefanbeller@googlemail.com>
---
 Documentation/generateShortOptions.py | 460 ++++++++++++++++++++++++++++++++++
 1 file changed, 460 insertions(+)
 create mode 100644 Documentation/generateShortOptions.py

diff --git a/Documentation/generateShortOptions.py b/Documentation/generateShortOptions.py
new file mode 100644
index 0000000..1d326f9
--- /dev/null
+++ b/Documentation/generateShortOptions.py
@@ -0,0 +1,460 @@
+#!/usr/bin/python
+# This script generates a table, which should help you getting a
+# better overview of the existing long and short options of the
+# various git commands. This script actually is only suited for
+# generating the table itself, as the collection of the options of
+# the git commands needs to be done manually.
+# For the majority of commands, which are written in C, a small patch
+# such as the following helps to extract the relevant cases for this
+# script. However you still need to go through the shell commands
+# manually.
+# diff --git a/parse-options.c b/parse-options.c
+# index 62e9b1c..b356ca9 100644
+# --- a/parse-options.c
+# +++ b/parse-options.c
+# @@ -500,6 +500,12 @@ int parse_options(int argc, const char **argv, const char *prefix,
+#  {
+#  	struct parse_opt_ctx_t ctx;
+#
+# +	for (; options->type != OPTION_END; options++) {
+# +		if (options->long_name && options->short_name)
+# +			printf("%s,  %c, %s\n", argv[0], options->short_name, options->long_name);
+# +	}
+# +	exit(1);
+# +
+#  	parse_options_start(&ctx, argc, argv, prefix, options, flags);
+#  	switch (parse_options_step(&ctx, options, usagestr)) {
+#  	case PARSE_OPT_HELP:
+# --
+
+
+# Command, short option, long option
+cmd_results="""add,  n, dry-run
+add,  v, verbose
+add,  i, interactive
+add,  p, patch
+add,  e, edit
+add,  f, force
+add,  u, update
+add,  N, intent-to-add
+add,  A, all
+
+am, i, interactive
+am, 3, 3way
+am, q, quiet
+am, s, signoff
+am, u, utf8
+am, k, keep
+
+annotate, p, porcelain
+
+apply,  3, 3way
+apply,  R, reverse
+apply,  v, verbose
+
+archive,  o, output
+
+blame, p, porcelain
+blame, f, show-name
+blame, n, show-number
+blame, e, show-email
+
+branch,  v, verbose
+branch,  q, quiet
+branch,  t, track
+branch,  u, set-upstream-to
+branch,  r, remotes
+branch,  a, all
+branch,  d, delete
+branch,  m, move
+branch,  l, create-reflog
+branch,  f, force
+
+check-attr,  a, all
+
+check-ignore,  q, quiet
+check-ignore,  v, verbose
+check-ignore,  n, non-matching
+
+checkout,  q, quiet
+checkout,  t, track
+checkout,  2, ours
+checkout,  3, theirs
+checkout,  f, force
+checkout,  m, merge
+checkout,  p, patch
+
+checkout-index,  a, all
+checkout-index,  f, force
+checkout-index,  q, quiet
+checkout-index,  n, no-create
+checkout-index,  u, index
+
+cherry,  v, verbose
+
+cherry-pick,  n, no-commit
+cherry-pick,  e, edit
+cherry-pick,  s, signoff
+cherry-pick,  m, mainline
+cherry-pick,  X, strategy-option
+
+clean,  q, quiet
+clean,  n, dry-run
+clean,  f, force
+clean,  i, interactive
+clean,  e, exclude
+
+clone,  v, verbose
+clone,  q, quiet
+clone,  n, no-checkout
+clone,  l, local
+clone,  s, shared
+clone,  o, origin
+clone,  b, branch
+clone,  u, upload-pack
+clone,  c, config
+
+commit,  q, quiet
+commit,  v, verbose
+commit,  F, file
+commit,  m, message
+commit,  c, reedit-message
+commit,  C, reuse-message
+commit,  s, signoff
+commit,  t, template
+commit,  e, edit
+commit,  S, gpg-sign
+commit,  a, all
+commit,  i, include
+commit,  p, patch
+commit,  o, only
+commit,  n, no-verify
+commit,  z, null
+commit,  u, untracked-files
+
+config,  f, file
+config,  l, list
+config,  e, edit
+config,  z, null
+
+count-objects,  v, verbose
+count-objects,  H, human-readable
+
+diff, u, patch
+diff, p, patch
+diff, U, unified
+diff, B, break-rewrites
+diff, M, find-renames
+diff, C, find-copies
+diff, D, irreversible-delete
+diff, a, text
+diff, b, ignore-space-change
+diff, w, ignore-all-space
+diff, W, function-context
+
+diff-files, u, patch
+diff-files, p, patch
+diff-files, U, unified
+diff-files, B, break-rewrites
+diff-files, M, find-renames
+diff-files, C, find-copies
+diff-files, D, irreversible-delete
+diff-files, a, text
+diff-files, b, ignore-space-change
+diff-files, w, ignore-all-space
+diff-files, W, function-context
+diff-files, c, cc
+# diff-index and diff-tree similar, to be done
+
+fetch,  v, verbose
+fetch,  q, quiet
+fetch,  a, append
+fetch,  f, force
+fetch,  m, multiple
+fetch,  t, tags
+fetch,  p, prune
+fetch,  k, keep
+fetch,  u, update-head-ok
+
+filter-branch, f, force
+
+fmt-merge-msg,  m, message
+fmt-merge-msg,  F, file
+
+for-each-ref,  s, shell
+for-each-ref,  p, perl
+
+format-patch,  n, numbered
+format-patch,  N, no-numbered
+format-patch,  s, signoff
+format-patch,  v, reroll-count
+format-patch,  o, output-directory
+format-patch,  k, keep-subject
+format-patch,  p, no-stat
+format-patch,  q, quiet
+
+fsck,  v, verbose
+
+fsck-objects,  v, verbose
+
+gc,  q, quiet
+
+grep,  v, invert-match
+grep,  i, ignore-case
+grep,  w, word-regexp
+grep,  a, text
+grep,  E, extended-regexp
+grep,  G, basic-regexp
+grep,  F, fixed-strings
+grep,  P, perl-regexp
+grep,  n, line-number
+grep,  l, files-with-matches
+grep,  L, files-without-match
+grep,  z, null
+grep,  c, count
+grep,  C, context
+grep,  B, before-context
+grep,  A, after-context
+grep,  p, show-function
+grep,  W, function-context
+grep,  q, quiet
+grep,  O, open-files-in-pager
+
+help,  a, all
+help,  g, guides
+help,  m, man
+help,  w, web
+help,  i, info
+
+init,  q, quiet
+
+init-db,  q, quiet
+
+insta-web, l, local
+insta-web, d, httpd
+insta-web, m, module-path
+insta-web, p, port
+insta-web, b, browser
+
+log,  q, quiet
+
+ls-files,  c, cached
+ls-files,  d, deleted
+ls-files,  m, modified
+ls-files,  o, others
+ls-files,  i, ignored
+ls-files,  s, stage
+ls-files,  k, killed
+ls-files,  u, unmerged
+ls-files,  x, exclude
+ls-files,  X, exclude-from
+
+ls-tree,  l, long
+
+ls-remotes, h, heads
+ls-remotes, t, tags
+ls-remotes, u, upload-pack
+
+merge,  e, edit
+merge,  s, strategy
+merge,  X, strategy-option
+merge,  m, message
+merge,  n, no-stat
+merge,  v, verbose
+merge,  q, quiet
+merge,  S, gpg-sign
+merge,  s, strategy
+merge,  X, strategy-option
+
+merge-base,  a, all
+
+merge-file,  p, stdout
+merge-file,  q, quiet
+
+mv,  v, verbose
+mv,  n, dry-run
+mv,  f, force
+
+pack-objects,  q, quiet
+
+prune,  n, dry-run
+prune,  v, verbose
+
+prune-packed,  n, dry-run
+prune-packed,  q, quiet
+
+pull, a, append
+pull, f, force
+pull, k, keep
+pull, u, update-head-ok
+pull, n, no-stat
+pull, q, quiet
+pull, v, verbose
+pull, r, rebase
+pull,  s, strategy
+pull,  X, strategy-option
+
+push,  v, verbose
+push,  q, quiet
+push,  n, dry-run
+push,  f, force
+push,  u, set-upstream
+
+quilt-import, n, dry-run
+
+rebase, f, force-rebase
+rebase, i, interactive
+rebase, p, preserve-merges
+rebase, m, merge
+rebase, n, no-stat
+rebase, v, verbose
+rebase, r, rebase
+rebase,  s, strategy
+rebase,  X, strategy-option
+rebase, x, exec
+
+read-tree,  v, verbose
+read-tree,  n, dry-run
+
+reflog,  q, quiet
+
+rev-list, n, max-count
+rev-list, i, regexp-ignore-case
+rev-list, E, extended-regexp
+rev-list, F, fixed-strings
+rev-list, g, walk-reflogs
+
+remote,  v, verbose
+
+repack,  q, quiet
+repack,  l, local
+
+replace,  l, list
+replace,  d, delete
+replace,  f, force
+
+reset,  q, quiet
+reset,  p, patch
+
+revert,  n, no-commit
+revert,  e, edit
+revert,  s, signoff
+revert,  m, mainline
+revert,  X, strategy-option
+
+rm,  n, dry-run
+rm,  q, quiet
+rm,  f, force
+
+show,  q, quiet
+
+show-branch,  a, all
+show-branch,  r, remotes
+show-branch,  g, reflog
+
+show-ref,  d, dereference
+show-ref,  s, hash
+show-ref,  q, quiet
+
+shortlog, n, numbered
+shortlog, s, summary
+shortlog, e, email
+
+stash, p, patch
+stash, u, include-untracked
+stash, a, all
+stash, q, quiet
+
+stage,  n, dry-run
+stage,  v, verbose
+stage,  i, interactive
+stage,  p, patch
+stage,  e, edit
+stage,  f, force
+stage,  u, update
+stage,  N, intent-to-add
+stage,  A, all
+
+status,  v, verbose
+status,  s, short
+status,  b, branch
+status,  z, null
+status,  u, untracked-files
+
+stripspace, s, strip-comments
+stripspace, c, comment-lines
+
+submodule, q, quiet
+submodule, b, branch
+submodule, f, force
+submodule, n, summary-limit
+submodule, N, no-fetch
+
+symbolic-ref,  q, quiet
+symbolic-ref,  d, delete
+
+tag,  l, list
+tag,  d, delete
+tag,  v, verify
+tag,  a, annotate
+tag,  m, message
+tag,  F, file
+tag,  s, sign
+tag,  u, local-user
+tag,  f, force
+
+update-server-info,  f, force
+
+verify-pack,  v, verbose
+verify-pack,  s, stat-only
+
+verify-tag,  v, verbose
+
+whatchanged,  q, quiet"""
+
+import subprocess
+
+column_len = {}
+column_count = {}
+cmdoptions={}
+
+for line in cmd_results.split("\n"):
+	if not len(line) or line.startswith('#'):
+		continue
+	name, short, long = line.split(",")
+
+	if not short in column_len:
+		column_len[short] = len(long)
+		column_count[short] = 0
+	column_len[short] = max(column_len[short], len(long))
+	column_count[short] += 1
+
+	if not name in cmdoptions:
+		cmdoptions[name] = {}
+	cmdoptions[name][short] = long
+
+longest_cmd = 0
+for cmd in cmdoptions:
+	longest_cmd = max(longest_cmd, len(cmd))
+
+print " "*(longest_cmd-len("Name\\short")), "Name\\short",
+
+# let's sort the columns in a way, we can see most of the options on the left hand side
+columns = []
+for key, value in sorted(column_count.iteritems(), key=lambda (k,v): (-v,k)):
+	columns += [key]
+
+# print head line
+for short in columns:
+	print "|" + " "*(1+column_len[short]-len(short)) + short,
+print
+
+# print line for each command
+for cmd in sorted(cmdoptions):
+	print " "*(longest_cmd-len(cmd)), cmd,
+	for short in columns:
+		s = ""
+		if short in cmdoptions[cmd]:
+			s = cmdoptions[cmd][short]
+		print "|" + " "*(1+column_len[short]-len(s)) + s,
+	print "  ", cmd
-- 
1.8.4.1.605.g23c6912

  reply	other threads:[~2013-10-31 23:04 UTC|newest]

Thread overview: 49+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20131024122255.GI9378@mwanda>
     [not found] ` <20131024122512.GB9534@mwanda>
     [not found]   ` <20131026181709.GB10488@kroah.com>
2013-10-27  1:34     ` [PATCH] commit: Add -f, --fixes <commit> option to add Fixes: line Josh Triplett
2013-10-27  5:42       ` Michael Haggerty
2013-10-27  6:37         ` Theodore Ts'o
2013-10-27  7:14         ` Josh Triplett
2013-10-27  8:03           ` [Ksummit-2013-discuss] " Michel Lespinasse
2013-10-27  9:23             ` Josh Triplett
2013-10-27  8:09           ` Thomas Rast
2013-10-27  9:20             ` Josh Triplett
2013-10-27 10:59               ` Johan Herland
2013-10-27 19:10                 ` Christian Couder
2013-10-28  2:46                   ` Johan Herland
2013-10-28 22:10                     ` Thomas Rast
2013-10-29  2:02                       ` Jeff King
2013-10-30 17:53                       ` Johan Herland
2013-10-29  6:23                     ` Christian Couder
2013-10-30 19:07                       ` Johan Herland
2013-11-02 12:54                         ` Christian Couder
2013-10-27  9:26             ` Stefan Beller
2013-10-27 16:30               ` Thomas Rast
2013-10-27 17:03                 ` Stefan Beller
2013-10-31 23:03                 ` Stefan Beller
2013-10-31 23:04                   ` Stefan Beller [this message]
2013-10-31 23:09                     ` [PATCH] Documentation: add a script to generate a (long/short) options overview Stefan Beller
2013-10-31 23:45                       ` brian m. carlson
2013-11-01  0:09                         ` Junio C Hamano
2013-10-28  9:02           ` [PATCH] commit: Add -f, --fixes <commit> option to add Fixes: line Michael Haggerty
2013-10-28 11:29             ` Johan Herland
2013-10-29  2:08               ` Jeff King
2013-10-29  8:26                 ` Matthieu Moy
2013-10-30 18:12                 ` Johan Herland
2013-10-31  6:28                   ` Duy Nguyen
2013-10-31 17:20                     ` Junio C Hamano
2013-10-31 23:52                       ` Duy Nguyen
2013-11-01  0:16                       ` Johan Herland
2013-10-27  8:33       ` Duy Nguyen
2013-10-27  9:13         ` Josh Triplett
2013-10-28  0:49       ` Jim Hill
2013-10-28  1:52       ` Junio C Hamano
2013-10-28  7:16         ` Josh Triplett
2013-10-28  8:27           ` Michael Haggerty
2013-10-28  8:59           ` [ksummit-attendees] " Christoph Hellwig
2013-10-28 23:09             ` Benjamin Herrenschmidt
2013-10-28 23:38               ` Russell King - ARM Linux
2013-10-28 23:41               ` Russell King - ARM Linux
2013-10-28  9:08         ` Junio C Hamano
2013-10-29  4:45           ` Christian Couder
2013-10-29 19:54             ` Junio C Hamano
2013-10-30 17:28       ` Tony Luck
2013-10-30 18:33         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1383260682-12364-1-git-send-email-stefanbeller@googlemail.com \
    --to=stefanbeller@googlemail.com \
    --cc=git@vger.kernel.org \
    --cc=mhagger@alum.mit.edu \
    --cc=tr@thomasrast.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).