Bash completion script, list-projects, list-contexts commands.
* list-projects lists all the projects in the repo. * list-contexts lists all the context in the repo. * Created a bash completion script to allow auto-complete for GTD.
This commit is contained in:
parent
a780d972f1
commit
4c5f514fb4
@ -1,8 +1,8 @@
|
||||
#Tue, 16 Dec 2014 10:49:37 -0600
|
||||
#Tue, 16 Dec 2014 11:59:49 -0600
|
||||
lib.local=true
|
||||
name=jdb-gtd
|
||||
version=1.13
|
||||
version=1.14
|
||||
nailgun.classpath.dir=/home/jdbernard/programs/nailgun/classpath
|
||||
executable.jar=true
|
||||
main.class=com.jdblabs.gtd.cli.GTDCLI
|
||||
build.number=2
|
||||
build.number=5
|
||||
|
39
resources/etc/bash_completion.d/gtd
Normal file
39
resources/etc/bash_completion.d/gtd
Normal file
@ -0,0 +1,39 @@
|
||||
_gtd()
|
||||
{
|
||||
local cur prev topOpts debugOpts logLevels
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
topOpts="help process done calendar list-copies new tickler list debug delegate rename-project list-projects list-contexts"
|
||||
debugOpts="state loglevel"
|
||||
logLevels="TRACE DEBUG INFO WARN ERROR"
|
||||
|
||||
case "${prev}" in
|
||||
help)
|
||||
COMPREPLY=( $(compgen -W "${topOpts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
done|list-copies|delegate)
|
||||
COMPREPLY=( $(compgen -f ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
ls|list)
|
||||
COMPREPLY=( $(gtd list-projects) $(gtd list-contexts) )
|
||||
return 0
|
||||
;;
|
||||
debug)
|
||||
COMPREPLY=( $(compgen -W "${debugOpts}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
loglevel)
|
||||
COMPREPLY=( $(compgen -W "${logLevels}" -- ${cur}) )
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
COMPREPLY=( $(compgen -W "${topOpts}" -- ${cur}) )
|
||||
return 0
|
||||
}
|
||||
complete -F _gtd gtd
|
@ -21,6 +21,7 @@ import java.io.FileFilter
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.security.MessageDigest
|
||||
import groovy.io.FileType
|
||||
import org.joda.time.DateMidnight
|
||||
import org.joda.time.DateTime
|
||||
import org.slf4j.Logger as SFL4JLogger
|
||||
@ -35,7 +36,7 @@ import static java.nio.file.StandardCopyOption.*
|
||||
* @org gtd.jdb-labs.com/cli/GTDCLI */
|
||||
public class GTDCLI {
|
||||
|
||||
public static final String VERSION = "1.13"
|
||||
public static final String VERSION = "1.14"
|
||||
private static String EOL = System.getProperty("line.separator")
|
||||
|
||||
/// We have a persistent instance when we are in the context of a Nailgun
|
||||
@ -244,6 +245,8 @@ public class GTDCLI {
|
||||
case ~/list-copies/: listCopies(parsedArgs); break
|
||||
case ~/new/: newAction(parsedArgs); break
|
||||
case ~/tickler/: tickler(parsedArgs); break
|
||||
case ~/list-contexts/: listContexts(parsedArgs); break;
|
||||
case ~/list-projects/: listProjects(parsedArgs); break;
|
||||
case ~/ls|list/: ls(parsedArgs); break;
|
||||
case ~/debug/: debug(parsedArgs); break;
|
||||
case ~/delegate/: delegateAction(parsedArgs); break;
|
||||
@ -651,6 +654,29 @@ public class GTDCLI {
|
||||
printItems(new File(gtdDirs.waiting, target))
|
||||
printItems(new File(gtdDirs.projects, target)) } }
|
||||
|
||||
/** #### `listProjects`
|
||||
* Implement the `list-projects` command to list all the known projects
|
||||
* for this repository. For detailed information see the
|
||||
* [online help][help-list-projects] by running `gtd help list-projects`.
|
||||
*
|
||||
* [help-list-projects]: jlp://gtd.jdb-labs.com/cli/GTDCLI/help/list-projects
|
||||
*/
|
||||
protected void listProjects(LinkedList args) {
|
||||
gtdDirs.projects.eachFile(FileType.DIRECTORIES) { println it.name } }
|
||||
|
||||
/** #### `listContexts`
|
||||
* Implement the `list-contexts` command to list all the known contexts
|
||||
* for this repository. For detailed information see the
|
||||
* [online help][help-list-contexts] by running `gtd help list-contexts`.
|
||||
*
|
||||
* [help-list-contexts]: jlp://gtd.jdb-labs.com/cli/GTDCLI/help/list-contexts
|
||||
*/
|
||||
protected void listContexts(LinkedList args) {
|
||||
def ctxNames = []
|
||||
gtdDirs["next-actions"].eachFile(FileType.DIRECTORIES) { ctxNames << it.name }
|
||||
gtdDirs.waiting.eachFile(FileType.DIRECTORIES) { ctxNames << it.name }
|
||||
ctxNames.unique().each { println it } }
|
||||
|
||||
/** #### `debug`
|
||||
* Print out debug information. Currently this prints out the internal
|
||||
* state of the CLI. I may add other subcommands if the need arises. */
|
||||
@ -1012,6 +1038,7 @@ This command lists all the tasks for a given context or project. The purpose is
|
||||
to list in one place items that are sitting in the next-actions folder or the
|
||||
waiting folder for a specific context or list items for a given project. If no
|
||||
context or project is named, all contexts are listed."""
|
||||
break
|
||||
|
||||
/// Online help for the `delegate` command.
|
||||
/// @org gtd.jdb-labs.com/cli/GTDCLI/help/delegate
|
||||
@ -1021,6 +1048,25 @@ usage gtd delegate [<action-file> ...]
|
||||
This command moves an action item from a next-action context or project folder
|
||||
to the delegate folder. It allows the user to attach the name of the newly
|
||||
responsible party and optionally rename the item."""
|
||||
break
|
||||
|
||||
/// Online help for the `list-projects` command.
|
||||
/// @org gtd.jdb-labs.com/cli/GTDCLI/hemp/list-projects
|
||||
case ~/list-projects/: println """\
|
||||
usage gtd list-projects
|
||||
|
||||
This command lists all of the project folders defined in this repository (all
|
||||
the folders in the /projects folder."""
|
||||
break
|
||||
|
||||
/// Online help for the `list-contexts` command.
|
||||
/// @org gtd.jdb-labs.com/cli/GTDCLI/hemp/list-contexts
|
||||
case ~/list-contexts/: println """\
|
||||
usage gtd list-contexts
|
||||
|
||||
This command lists all of the context folders defined in this repository (all
|
||||
the folders in the /next-actions and /waiting folders."""
|
||||
break
|
||||
|
||||
/// Online help for the `rename-project` command.
|
||||
/// @org gtd.jdb-labs.com/cli/GTDCLI/help/rename-project
|
||||
@ -1030,6 +1076,7 @@ usage gtd rename-project <existing-project> <new-name>
|
||||
|
||||
This command renames a project directory and updates any items that reference
|
||||
the project."""
|
||||
break
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user