zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: <joerg@alea.gnuu.de>, zsh-workers@sunsite.dk
Subject: Re: run-help: Support for svn and git
Date: Sun, 30 Dec 2007 20:02:04 -0800	[thread overview]
Message-ID: <071230200204.ZM32486@torch.brasslantern.com> (raw)
In-Reply-To: <slrnfnfrql.cgh.joerg@alea.gnuu.de>

On Dec 30,  7:19pm, joerg@alea.gnuu.de wrote:
}
} calling run-help for svn or git is often not very helpful.
} 
} Would you include this change?

I don't think there's any reason to give git and/or svn any special
treatment that isn't applied to (say) cvs or apt or yum or ztcp or
zftp or any other command that uses "subcommands".

I also don't think it's the right approach to build special knowledge
into run-help of all possible commands that have subcommands.

If we're going to make a change for this it should be one that can
also be applied to "perl someprog.plx" or "sh yourscript.sh".

So, how about the below (which replaces the patch I sent in 243260).
This looks for a function (or alias or command) named "run-help-$1",
e.g. run-help-git or run-help-svn or run-help-perl or whatever.  If
one is found, it invokes that, otherwise it invokes "man" as always.

Then one can do:

    run-help-svn () {
      local cmd_args
      cmd_args=( ${@:#-*} )
      svn help $cmd_args[1]
    }

And something similar for git.

Of course at this point we ought to add something to the manual (in the
contributions section, perhaps?) about the run-help function and its,
um, helpers.

Index: Functions/Misc/run-help
===================================================================
diff -c -r1.3 run-help
--- Functions/Misc/run-help	30 May 2007 03:36:56 -0000	1.3
+++ Functions/Misc/run-help	31 Dec 2007 02:51:44 -0000
@@ -85,7 +85,20 @@
 	man zshmisc
 	;;
     (*)
-	((! didman++)) && man $@
+        set -- $@:t
+	if ((! didman++))
+	then
+	    if whence -w "run-help-$1" >/dev/null
+	    then
+		local cmd_args
+		builtin getln cmd_args
+		builtin print -z "$cmd_args"
+		cmd_args=( ${${(z)cmd_args}[2,-1]} )
+		eval "run-help-$1 $cmd_args[@]"
+	    else
+		man $1
+	    fi
+	fi
 	;;
     esac
     if ((i < $#places && ! didman))


  reply	other threads:[~2007-12-31  4:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-30 19:19 Jörg Sommer
2007-12-31  4:02 ` Bart Schaefer [this message]
2007-12-31 12:10   ` Jörg Sommer
2007-12-31 16:19     ` Bart Schaefer
2007-12-31 17:26       ` Jörg Sommer
2007-12-31 21:05         ` Bart Schaefer
2007-12-31 18:24   ` Jörg Sommer
2007-12-31 21:08     ` Bart Schaefer
2008-01-04  0:18       ` Clint Adams
2008-01-04  3:21         ` Bart Schaefer
2008-01-04  4:32           ` Clint Adams
2008-01-05 18:05             ` Bart Schaefer
2008-01-09 19:07               ` Clint Adams
2008-01-13 19:01                 ` Bart Schaefer
2008-01-04 12:13         ` Jörg Sommer

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

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

  git send-email \
    --in-reply-to=071230200204.ZM32486@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=joerg@alea.gnuu.de \
    --cc=zsh-workers@sunsite.dk \
    /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://git.vuxu.org/mirror/zsh/

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 NNTP newsgroup(s).