From wmorgan-ditz at masanjin.net Tue Jul 15 20:47:53 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Tue, 15 Jul 2008 17:47:53 -0700 Subject: [ditz-talk] ditz debian package available Message-ID: <1216169257-sup-8136@entry> Thanks to Christian Garbs: http://www.cgarbs.de/stuff/deb-repository.html#ditz -- William From mitch at cgarbs.de Sun Jul 20 06:46:46 2008 From: mitch at cgarbs.de (Christian Garbs) Date: Sun, 20 Jul 2008 12:46:46 +0200 Subject: [ditz-talk] bash completion Message-ID: <20080720104646.GA28085@cgarbs.de> Hi! The current ditz bash completion[1] is very simple (it's my first try at writing a completion). The first parameter is expanded to the ditz command list (obtained via the secret parameter `ditz --commands`). The second parameter is expanded to all open issues (via `ditz todo 2>/dev/null | grep '^. ' | cut -c 3- | cut -d : -f 1`). Unfortunately this simplification makes "ditz release" expand to the open issues and not to the open releases. I'm working on fixing this and providing proper completions for every command, but I don't know how to get lists of these items properly: - all issues (for 'ditz comment' etc.) - all open issues (for 'ditz close')[2] - all unstarted issues (for 'start') - all started issues ('stop') - all assigned issues ('unassign') - all releases ('add-release', 'archive', 'changelog', ...) - unreleased releases ('release') - all components ('set-component') Would it be possible to add other secret switches like 'ditz --commands' to print these lists of items? Regards, Christian [1] commit cfb08b623811664387829977a927be4921d1439e [2] I can get this like described above, but a direct output from ditz would be faster. -- ....Christian.Garbs.....................................http://www.cgarbs.de Incorrigible punster -- Do not incorrige. From wmorgan-ditz at masanjin.net Sun Jul 20 18:28:27 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Sun, 20 Jul 2008 15:28:27 -0700 Subject: [ditz-talk] bash completion In-Reply-To: <20080720104646.GA28085@cgarbs.de> References: <20080720104646.GA28085@cgarbs.de> Message-ID: <1216592790-sup-5981@entry> Reformatted excerpts from Christian Garbs's message of 2008-07-20: > - all issues (for 'ditz comment' etc.) > - all open issues (for 'ditz close')[2] > - all unstarted issues (for 'start') > - all started issues ('stop') > - all assigned issues ('unassign') > > - all releases ('add-release', 'archive', 'changelog', ...) > - unreleased releases ('release') > > - all components ('set-component') > > Would it be possible to add other secret switches like 'ditz > --commands' to print these lists of items? Yes, it's possible and easy. And I think having ditz output these lists in an easily-parseable way is the right idea. I'll spend a little time on this. Thanks for the bash completion, btw! -- William From wmorgan-ditz at masanjin.net Mon Jul 21 13:07:39 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Mon, 21 Jul 2008 10:07:39 -0700 Subject: [ditz-talk] bash completion In-Reply-To: <1216592790-sup-5981@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> Message-ID: <1216659978-sup-343@entry> I forgot that there's already some support for command-specific option completion (if you pass "" as the argument to a command), so I'll work on extending that for all commands. Then the completion scripts can be kept quite simple and don't have to know about the specifics of ditz commands. -- William From wmorgan-ditz at masanjin.net Mon Jul 21 20:52:38 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Mon, 21 Jul 2008 17:52:38 -0700 Subject: [ditz-talk] bash completion In-Reply-To: <1216659978-sup-343@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> Message-ID: <1216687798-sup-7262@entry> Ok, check out the master branch. You should be able to call it with "" at any argument position to get the list of possible completions. E.g. "ditz assign " prints the list of all issues, and "ditz assign ditz-5 " prints the list of all releases. -- William From mitch at cgarbs.de Mon Jul 21 15:42:40 2008 From: mitch at cgarbs.de (Christian Garbs) Date: Mon, 21 Jul 2008 21:42:40 +0200 Subject: [ditz-talk] bash completion In-Reply-To: <1216659978-sup-343@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> Message-ID: <20080721194240.GA13676@cgarbs.de> On Mon, Jul 21, 2008 at 10:07:39AM -0700, William Morgan wrote: > I forgot that there's already some support for command-specific option > completion (if you pass "" as the argument to a command), so > I'll work on extending that for all commands. Sounds good, but there might be a problem: When all ditz arguments are expanded, the shell needs to expand further arguments by itself, e.g. filenames if your did some kind of redirection of your output. But I don't understand enough about bash completion yet, I'll just have to see and try it to evaluate this. Regards, Christian -- ....Christian.Garbs.....................................http://www.cgarbs.de YA BRO NETA From mitch at cgarbs.de Tue Jul 22 09:40:02 2008 From: mitch at cgarbs.de (Christian Garbs) Date: Tue, 22 Jul 2008 15:40:02 +0200 Subject: [ditz-talk] bash completion In-Reply-To: <1216687798-sup-7262@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> <1216687798-sup-7262@entry> Message-ID: <20080722134002.GA4274@cgarbs.de> On Mon, Jul 21, 2008 at 05:52:38PM -0700, William Morgan wrote: > Ok, check out the master branch. You should be able to call it with > "" at any argument position to get the list of possible > completions. > > E.g. "ditz assign " prints the list of all issues, and "ditz > assign ditz-5 " prints the list of all releases. This works great! The relevant part for the bash completion is this: _ditz() { cur=${COMP_WORDS[COMP_CWORD]} if [ $COMP_CWORD -eq 1 ]; then COMPREPLY=( $( compgen -W "$(ditz --commands)" $cur ) ) elif [ $COMP_CWORD -eq 2 ]; then cmd=${COMP_WORDS[1]} COMPREPLY=( $( compgen -W "$(ditz "$cmd" '' 2>/dev/null)" $cur ) ) elif [ $COMP_CWORD -eq 3 ]; then cmd=${COMP_WORDS[1]} parm1=${COMP_WORDS[2]} COMPREPLY=( $( compgen -W "$(ditz "$cmd" "$parm1" '' 2>/dev/null)" $cur ) ) fi } Currently the if..elif..fi needs to be expanded if there would be a command with three arguments. You could propably refactor it to use a list but this way it's easier to understand. I've noticed that only mandatory arguments are expanded. It would be nice to expand optional arguments, too, eg. 'ditz help ' giving a list of all commands. ditz add-release [name] ditz assign [release] ditz help [command] ditz set-component [component] ditz status [release] ditz todo [release] ditz todo-full [release] This does not need to be done for [dir] arguments (like in ditz archive or ditz html) as filename/directory expansion is the default expansion mechanism of the shell. Regards, Christian -- ....Christian.Garbs.....................................http://www.cgarbs.de The Consultant's Curse: When the customer has beaten upon you long enough, give him what he asks for, instead of what he needs. This is very strong medicine, and is normally only required once. From wmorgan-ditz at masanjin.net Wed Jul 23 17:50:00 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Wed, 23 Jul 2008 14:50:00 -0700 Subject: [ditz-talk] bash completion In-Reply-To: <20080722134002.GA4274@cgarbs.de> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> <1216687798-sup-7262@entry> <20080722134002.GA4274@cgarbs.de> Message-ID: <1216849650-sup-4569@entry> Reformatted excerpts from Christian Garbs's message of 2008-07-22: > The relevant part for the bash completion is this: [snip] Thanks! > I've noticed that only mandatory arguments are expanded. It would be > nice to expand optional arguments, too, eg. 'ditz help ' > giving a list of all commands. I don't think it's an issue of mandatory vs optional. It's an issue of 'ditz help ' specifically not listing anything. I've fixed that in master. Try it all out and let me know how it goes. -- William From wmorgan-ditz at masanjin.net Wed Jul 23 17:56:29 2008 From: wmorgan-ditz at masanjin.net (William Morgan) Date: Wed, 23 Jul 2008 14:56:29 -0700 Subject: [ditz-talk] bash completion In-Reply-To: <1216849650-sup-4569@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> <1216687798-sup-7262@entry> <20080722134002.GA4274@cgarbs.de> <1216849650-sup-4569@entry> Message-ID: <1216850161-sup-4087@entry> Reformatted excerpts from William Morgan's message of 2008-07-23: > Try it all out and let me know how it goes. Seems to work great for me, btw. -- William From mitch at cgarbs.de Thu Jul 24 14:45:47 2008 From: mitch at cgarbs.de (Christian Garbs) Date: Thu, 24 Jul 2008 20:45:47 +0200 Subject: [ditz-talk] bash completion In-Reply-To: <1216849650-sup-4569@entry> References: <20080720104646.GA28085@cgarbs.de> <1216592790-sup-5981@entry> <1216659978-sup-343@entry> <1216687798-sup-7262@entry> <20080722134002.GA4274@cgarbs.de> <1216849650-sup-4569@entry> Message-ID: <20080724184547.GA17379@cgarbs.de> On Wed, Jul 23, 2008 at 02:50:00PM -0700, William Morgan wrote: > I don't think it's an issue of mandatory vs optional. It's an issue of > 'ditz help ' specifically not listing anything. I've fixed that > in master. Try it all out and let me know how it goes. It works great! I especially like how the issue numbers are expanded together with their headline. I've tested every command and this is the only thing I've found: `ditz add-release ` could list all existing releases -- if the release name gets longer (perhaps including a branch name) you could take an existing release and change a part of it. By chance I ran into the following problem: The completion script redirects error output to /dev/null to not mess up the screen on possible problems. I made a test directory under /tmp where ditz could not find a .ditz-config. So the completion just "hung" because ditz was waiting for me to enter my name and mail adress - but I could not see that. Could the check for .ditz-config be turned off when an