github.com/grantbow/bug@v0.3.1/bugapp/Help.go (about)

     1  package bugapp
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  func Help(args ...string) {
     9  	var cmd string
    10  	if args == nil {
    11  		cmd = "help"
    12  
    13  	}
    14  	if len(args) <= 1 {
    15  		cmd = "help"
    16  	} else {
    17  		cmd = args[1]
    18  	}
    19  	switch cmd {
    20  	case "create":
    21  		fmt.Printf("Usage: " + os.Args[0] + " create [-n] [options] Issue Title\n\n")
    22  		fmt.Printf(
    23  			`This will create an issue with the title Issue Title.  An editor 
    24  will be opened automatically for you to enter a more detailed 
    25  description. If your EDITOR environment variable is set, it 
    26  will be used, otherwise the default editor is vim.
    27  
    28  If the first argument to create is "-n", then %s will not open 
    29  any editor and create an empty Description.
    30  
    31  Options take a value and set a field on the bug at the same
    32  time as creating it. Valid options are:
    33      --status     Sets the bug status to the next parameter
    34      --tag        Tags the bug with a tag on creation
    35      --priority   Sets the priority to the next parameter
    36      --milestone  Sets the milestone to the next parameter
    37      --identifier Sets the identifier to the next parameter
    38  `, os.Args[0])
    39  	case "list":
    40  		fmt.Printf("Usage: " + os.Args[0] + " list [BugIDs]\n")
    41  		fmt.Printf("       " + os.Args[0] + " list [tags]\n\n")
    42  		fmt.Printf(
    43  			`This will list the issues found in the current environment
    44  
    45  With no arguments, titles will be printed to the screen along
    46  with the issue number that can be used to reference this issue
    47  on the command line.
    48  
    49  If 1 or more BugIDs are provided, the whole issue including
    50  description will be printed to STDOUT.  See "bug help identifiers"
    51  for a description of what makes a BugID.
    52  
    53  If, instead of BugIDs, you provide list with 1 or more tags, 
    54  it will print any issues which have that tag (in short form).
    55  
    56  Note that BugIDs may change as you create, edit, and close other
    57  unless yo have defined a stable identifier for the issue. Again,
    58  see "bug help identifiers."
    59  
    60  The subcommand "view" is an alias for "list".
    61  `)
    62  
    63  	case "edit":
    64  		fmt.Printf("Usage: " + os.Args[0] + " edit [Filename] BugID\n\n")
    65  		fmt.Printf(
    66  			`This will launch your standard editor to edit the description 
    67  of the bug identified by BugID.  See "bug help identifiers" for a 
    68  description of what makes a BugID.
    69  
    70  If the Filename option is provided, bug will instead launch an editor
    71  to edit that file name within the bug directory. Files that have
    72  special meaning to bug (Status, Milestone, Priority, Identifier) are
    73  treated in a case insensitive manner, otherwise the filename is passed
    74  directly to your editor.
    75  `)
    76  	case "status":
    77  		fmt.Printf("Usage: " + os.Args[0] + " status BugID [NewStatus]\n\n")
    78  		fmt.Printf(
    79  			`This will edit or display the status of the bug identified by BugID.
    80  See "bug help identifiers" for a description of what constitutes a BugID.
    81              
    82  If NewStatus is provided, it will update the first line of the Status file
    83  for the issue (creating the file as necessary). If not provided, it will 
    84  display the first line of the Status file to STDOUT.
    85  
    86  Note that you can edit the status in your standard editor with the
    87  command "%s edit status BugID". If you provide a longer than 1 line
    88  status with "bug edit status", "bug status" will preserve everything
    89  after the first line when editing a status. You can use this to provide
    90  further context on a status (for instance, why that status is setup.)
    91  `, os.Args[0])
    92  	case "priority":
    93  		fmt.Printf("Usage: " + os.Args[0] + " priority BugID [NewPriority]\n\n")
    94  		fmt.Printf(
    95  			`This will edit or display the priority of BugID. See "bug help identifiers"
    96  for a description of what constitutes a BugID.
    97  
    98  By convention, priorities should be an integer number (higher is more 
    99  urgent), but that is not enforced by this command and NewPriority can
   100  be any free-form text if you prefer.
   101              
   102  If NewPriority is provided, it will update the first line of the Priority
   103  file for the issue (creating the file as necessary). If not provided, it 
   104  will display the first line of the Priority file to STDOUT.
   105  
   106  Note that you can manually edit the Priority file in the issues/ directory
   107  by running "%s edit priority BugID", to provide further explanation (for 
   108  instance, why that priority is set.) This command will preserve the 
   109  explanation when updating a priority.
   110  `, os.Args[0])
   111  	case "milestone":
   112  		fmt.Printf("Usage: " + os.Args[0] + " milestone BugID [NewMilestone]\n\n")
   113  		fmt.Printf(
   114  			`This will edit or display the milestone of the identified by BugID.
   115  See "%s help identifiers" for a description of what constitutes a BugID.
   116  
   117  There are no restrictions on how milestones must be named, but
   118  semantic versioning is a good convention to adopt. Failing that,
   119  it's a good idea to use milestones that collate properly when
   120  sorted as strings so that they appear properly in "%s roadmap".
   121  
   122  If NewMilestone is provided, it will update the first line of the
   123  Milestone file for the issue (creating the file as necessary). 
   124  If not provided, it will display the first line of the Milestone 
   125  file to STDOUT.
   126  
   127  Note that you can manually edit the Milestone file in the issues/
   128  directory to provide further explanation (for instance, why that 
   129  milestone is set) with the command "bug edit milestone BugID"
   130  
   131  This command will preserve the explanation when updating a priority.
   132  `, os.Args[0])
   133  	case "retitle", "mv", "rename", "relabel":
   134  		fmt.Printf("Usage: " + os.Args[0] + " relabel BugID New Title\n\n")
   135  		fmt.Printf(
   136  			`This will change the title of BugID to "New Title". Use this
   137  to rename an issue.
   138  
   139  "%s mv", "%s retitle", and "%s rename" are all aliases for "%s relabel".
   140  `, os.Args[0], os.Args[0], os.Args[0], os.Args[0])
   141  	case "rm", "close":
   142  		fmt.Printf("Usage: " + os.Args[0] + " close BugID\n")
   143  		fmt.Printf("       " + os.Args[0] + " rm BugID\n\n")
   144  		fmt.Printf(
   145  			`This will delete the issue identifier by BugID. See
   146  "%s help identifiers" for details on what constitutes a BugID.
   147  
   148  Note that closing a bug may cause existing BugIDs to change if
   149  they do not have a stable identifier set (see "%s help identifiers",
   150  again.)
   151  
   152  Also note that this does not remove the issue from git, but only 
   153  from the file system. You'll need to execute "bug commit" to
   154  remove the bug from source control.
   155  
   156  "%s rm" is an alias for this "%s close"
   157  `, os.Args[0], os.Args[0], os.Args[0], os.Args[0])
   158  	case "purge":
   159  		fmt.Printf("Usage: " + os.Args[0] + " purge\n\n")
   160  		fmt.Printf(
   161  			`This will delete any bugs that are not currently tracked by
   162  git.
   163  `)
   164  	case "commit":
   165  		fmt.Printf("Usage: " + os.Args[0] + " commit [--no-autoclose]\n\n")
   166  		fmt.Printf(`This will commit any new, modified, or removed issues to
   167  git or hg.
   168  
   169  Your working tree and staging area should be otherwise
   170  unaffected by using this command.
   171  
   172  If the --no-autoclose option is passed to commit, bug will
   173  not include a "Closes #x" line for each issue imported from
   174  "bug-import --github." Otherwise, the commit message will
   175  include the list of issues that were closed so that GitHub
   176  will autoclose them when the changes are pushed upstream.
   177  `)
   178  	case "env":
   179  		fmt.Printf("Usage: " + os.Args[0] + " env\n\n")
   180  		fmt.Printf(`This will print the environment used by the bug command to stdout.
   181  
   182  Use this command if you want to see what directory bug create is
   183  using to store bugs, or what editor will be invoked by bug create/edit.
   184  `)
   185  
   186  	case "dir", "pwd":
   187  		fmt.Printf("Usage: " + os.Args[0] + " dir\n\n")
   188  		fmt.Printf(
   189  			`This will print the undecorated bug directory to stdout, 
   190  so you can use it as a subcommand for arguments to any 
   191  arbitrary shell commands. For example "cd $(bug dir)"
   192  
   193  "%s dir" is an alias for "%s pwd"
   194  `, os.Args[0], os.Args[0])
   195  	case "tag":
   196  		fmt.Printf("Usage: " + os.Args[0] + " tag [--rm] BugID [tags]\n\n")
   197  		fmt.Printf(`This will tag the given BugID with the tags
   198  given as parameters. At least one tag is required.
   199  
   200  Tags can be any string which would make a valid file name.
   201  
   202  If the --rm option is provided before the BugID, all tags provided will
   203  be removed instead of added.
   204  `)
   205  	case "roadmap":
   206  		fmt.Printf("Usage: " + os.Args[0] + " roadmap [options]\n\n")
   207  		fmt.Printf(
   208  			`This will print a markdown formatted list of all open
   209  issues, grouped by milestone.
   210  
   211  Valid options are:
   212      --simple      Don't show anything other than the title in the output
   213      --no-status   Don't show the status of an issue
   214      --no-priority Don't show the priority of an issue
   215      --no-identifier Don't include the bug identifier of an issue
   216      --tags        Include the tags attached to a bug in it's output
   217  
   218      --filter tag           Only show bugs matching tag
   219      --filter tag1,tag2,etc Only show issues matching at least one of
   220                             the supplied tags
   221  
   222  `)
   223  	case "id", "identifier":
   224  		fmt.Printf("Usage: " + os.Args[0] + " identifier BugID [--generate] [value]\n\n")
   225  		fmt.Printf(
   226  			`This will either set of retrieve the identifier for the bug
   227  currently identified by BugID.
   228  
   229  If value is provided as an argument, the bug identifier will be set
   230  to the value passed in. You should take care to ensure that any
   231  identifier used has at least 1 non-numeric character, to ensure there
   232  are no conflicts with automatically generated issue numbers used for
   233  a bug that has no explicit identifier set.
   234  
   235  If the --generate option is passed instead of a static value, a
   236  short identifier will be generated derived from the issue's current
   237  title (however, the identifier will remain unchanged if the bug's title
   238  is changed.)
   239  
   240  If only a BugID is provided, the current identifier will be printed.
   241  
   242  "%s id" is an alias for "%s identifier"
   243  `, os.Args[0], os.Args[0])
   244  	case "about", "version":
   245  		fmt.Printf("Usage: " + os.Args[0] + " version\n\n")
   246  		fmt.Printf(
   247  			`This will print information about the version of %s being
   248  invoked.
   249  
   250  "%s about" is an alias for "version".
   251  `, os.Args[0], os.Args[0])
   252  	case "identifiers":
   253  		fmt.Printf(
   254  			`Bugs can be referenced in 2 ways on the commandline, either by
   255  an index of where the bug directory is located inside the issues
   256  directory, or by an identifier. "BugID" can be either of these,
   257  and %s will try and intelligently guess which your command is
   258  referencing.
   259  
   260  By default, no identifiers are set for an issue. This means that
   261  the issue number provided in "%s list" is an index into the directory,
   262  and is unstable as bugs are created, modified, and closed. However,
   263  the benefit is that they are easy to reference and remember, at least
   264  in the short term.
   265  
   266  If you have longer lasting issues that need a stable identifier,
   267  they can be created by "%s identifier BugID NewIdentifier" to
   268  set the identifier of BugID to NewIdentifier. From that point
   269  forward, you can use NewIdentifier to reference the bug instead
   270  of the directory index.
   271  
   272  There are no rules for what constitutes a valid identifier, but
   273  you should try and ensure that they have at least 1 non-numeric
   274  character so that they don't conflict with directory indexes.
   275  
   276  If you just want an identifier but don't care what it is, you
   277  can use "%s identifier BugID --generate" to generate a new
   278  identifier for BugID.
   279  
   280  If there are no exact matches for the BugID provided, %s commands will
   281  also try and look up the bug by a substring match on all the valid 
   282  identifiers in the system before giving up.
   283  `, os.Args[0], os.Args[0], os.Args[0], os.Args[0], os.Args[0])
   284  
   285  	case "help":
   286  		fallthrough
   287  	default:
   288  		fmt.Printf("Usage: " + os.Args[0] + " command [options]\n\n")
   289  		fmt.Printf("Use \"bug help [command]\" for more information about any command below\n\n")
   290  		fmt.Printf("Valid commands\n")
   291  		fmt.Printf("\nIssue editing commands:\n")
   292  		fmt.Printf("\tcreate\t   File a new bug\n")
   293  		fmt.Printf("\tlist\t   List existing bugs\n")
   294  		fmt.Printf("\tedit\t   Edit an existing bug\n")
   295  		fmt.Printf("\ttag\t   Tag a bug with a category\n")
   296  		fmt.Printf("\tidentifier Set a stable identifier for the bug\n")
   297  		fmt.Printf("\trelabel\t   Rename the title of a bug\n")
   298  		fmt.Printf("\tclose\t   Delete an existing bug\n")
   299  		fmt.Printf("\tstatus\t   View or edit a bug's status\n")
   300  		fmt.Printf("\tpriority   View or edit a bug's priority\n")
   301  		fmt.Printf("\tmilestone  View or edit a bug's milestone\n")
   302  
   303  		fmt.Printf("\nSource control commands:\n")
   304  		fmt.Printf("\tcommit\t Commit any new, changed or deleted bug to git\n")
   305  		fmt.Printf("\tpurge\t Remove all issues not tracked by git\n")
   306  
   307  		fmt.Printf("\nOther commands:\n")
   308  		fmt.Printf("\tenv\t Show settings that bug will use if invoked from this directory\n")
   309  		fmt.Printf("\tpwd\t Prints the issues directory to stdout (useful subcommand in the shell)\n")
   310  		fmt.Printf("\troadmap\t Print list of open issues sorted by milestone\n")
   311  		fmt.Printf("\tversion\t Print the version of this software\n")
   312  		fmt.Printf("\thelp\t Show this screen\n")
   313  	}
   314  }