github.com/grantbow/fit@v0.7.1-0.20220916164603-1f7c88ac81e6/fitapp/Help.go (about) 1 package fitapp 2 3 import ( 4 "fmt" 5 "os" 6 ) 7 8 // Help is a subcommand to describe the program and it's subcommands. 9 func Help(args ...string) { 10 var cmd string 11 if args == nil || len(args) == 0 { 12 cmd = "help" 13 } else if len(args) == 1 { 14 //cmd = "help" 15 cmd = args[0] 16 } else if len(args) == 2 && (args[1] == "help" || args[1] == "--help") { 17 cmd = args[0] 18 } else { 19 cmd = args[1] 20 } 21 //fmt.Printf("cmd: %v\n", cmd) // debug 22 switch cmd { 23 case "create", "add", "new": 24 fmt.Printf("usage: " + os.Args[0] + " create [-n] [options] Issue Title\n\n") 25 fmt.Printf( 26 `This will create an issue with the title Issue Title. An editor 27 will be opened on Description automatically. If your EDITOR 28 environment variable is set, it will be used, otherwise 29 the default editor is vim. 30 31 If the first argument to create is "-n", then %s will not open 32 any editor and create an empty Description. 33 34 Options take a value and set a field on the issue at the same 35 time as creating it. Valid options are: 36 --status Sets status to the next argument 37 --tag Adds tag on creation 38 --priority Sets the priority to the next argument 39 --milestone Sets the milestone to the next argument 40 --identifier Sets the identifier to the next argument 41 --generate-id Automatically generate a stable issue identifier 42 43 aliases for create: add new 44 `, os.Args[0]) 45 case "list", "view", "show", "display", "ls": 46 fmt.Printf("usage: " + os.Args[0] + " list \n") 47 fmt.Printf(" " + os.Args[0] + " list <IssueID>...\n") 48 fmt.Printf(" " + os.Args[0] + " list <-t|--tags> <IssueID>...\n") 49 fmt.Printf(" " + os.Args[0] + " list <-m|--match> <regex>...\n") 50 fmt.Printf(" " + os.Args[0] + " list <tag>...\n\n") 51 fmt.Printf(" " + os.Args[0] + " list <-r|--recursive>...\n\n") 52 fmt.Printf( 53 `Lists the issues. 54 55 With no arguments, issue number and titles will be printed. 56 Issue numbers are used to reference particular issues. 57 If valid IssueIDs are provided, whole issues with Description 58 will print. See "fit help ids" for valid IssueIDs. 59 60 Use -t to list with tags, especially removing (case insensitive) closed 61 62 fit list -t | grep -iv closed 63 64 Provide a regular expression with the [-m|--match] option. 65 66 Recursive lists issues in subdirectories, not just the present directory. 67 68 Escape spcial characters. Many regular expressions use special 69 characters that must be escaped. Escaping prevents argument 70 "filename expansion" or "globbing" performed by the shell before 71 fit is passed the arguments. Two good references with details are: 72 http://tldp.org/LDP/abs/html/globbingref.html 73 https://www.gnu.org/software/bash/manual/html_node/Pattern-Matching.html 74 75 If 1 or more <tag>s are provided, matching issues are listed. 76 77 Note that IssueIDs may change as you create, edit, and close other 78 issues. Details are provided by "fit help ids." 79 80 aliases for list: view show display ls 81 `) 82 83 case "edit": 84 fmt.Printf("usage: " + os.Args[0] + " edit <IssueID> <Filename>\n\n") 85 fmt.Printf( 86 `This will launch your standard editor to edit the Description 87 of the issue identified by IssueID. See "fit help ids" for 88 what makes an IssueID. 89 90 If the Filename option is provided, fit will instead launch an editor 91 to edit that file name within the issue directory. Files that have 92 special meaning (Status, Milestone, Priority, Identifier) are treated 93 in a case insensitive manner, otherwise the filename is passed directly 94 to your editor. 95 `) 96 case "status": 97 fmt.Printf("usage: " + os.Args[0] + " status <IssueID> <NewStatus>\n\n") 98 fmt.Printf( 99 `This will edit or display the status of the issue identified by IssueID. 100 See "fit help ids" for what constitutes an IssueID. 101 102 If NewStatus is provided, it will update the first line of the Status file 103 for the issue (creating the file as necessary). If not provided, it will 104 display the first line of the Status file to STDOUT. 105 106 Note that you can edit the status in your standard editor with the 107 command "%s edit status <IssueID>". If you provide a longer than 1 line 108 status with "fit edit status", "fit status" will preserve everything 109 after the first line when editing a status. You can use this to provide 110 further context on a status (for instance, why that status is setup.) 111 `, os.Args[0]) 112 case "priority": 113 fmt.Printf("usage: " + os.Args[0] + " priority <IssueID> <New Priority>\n\n") 114 fmt.Printf( 115 `This will edit or display the priority of IssueID. See "fit help ids" 116 for what constitutes an IssueID. 117 118 By convention, priorities should be an integer number (higher is more 119 urgent), but that is not enforced by this command and <New Priority> can 120 be any free-form text if you prefer. 121 122 If <New Priority> is provided, it will update the first line of the Priority 123 file for the issue (creating the file as necessary). If not provided, it 124 will display the first line of the Priority file to STDOUT. 125 126 Note that you can manually edit the Priority file in the issues/ directory 127 by running "%s edit priority <IssueID>", to provide further explanation (for 128 instance, why that priority is set.) This command will preserve the 129 explanation when updating a priority. 130 `, os.Args[0]) 131 case "milestone": 132 fmt.Printf("usage: " + os.Args[0] + " milestone <IssueID> <New Milestone>\n\n") 133 fmt.Printf( 134 `This will edit or display the milestone of the identified by IssueID. 135 See "%s help ids" for what constitutes an IssueID. 136 137 There are no restrictions on how milestones must be named, but 138 semantic versioning is a good convention to adopt. Failing that, 139 it's a good idea to use milestones that collate properly when 140 sorted as strings so that they appear properly in "%s roadmap". 141 142 If <New Milestone> is provided, it will update the first line of the 143 Milestone file for the issue (creating the file as necessary). 144 If not provided, it will display the first line of the Milestone 145 file to STDOUT. 146 147 Note that you can manually edit the Milestone file in the issues/ 148 directory to provide further explanation (for instance, why that 149 milestone is set) with the command "fit edit milestone <IssueID>" 150 151 This command will preserve the explanation when updating a priority. 152 `, os.Args[0], os.Args[0]) 153 case "retitle", "mv", "rename", "relabel": 154 fmt.Printf("usage: " + os.Args[0] + " retitle <IssueID> <New Title>\n\n") 155 fmt.Printf( 156 `This will change the title of IssueID to <New Title>. Use this 157 to rename an issue. 158 159 aliases for retitle: mv rename relabel 160 `) 161 case "rm", "close": 162 fmt.Printf("usage: " + os.Args[0] + " close <IssueID>\n\n") 163 fmt.Printf( 164 `This will move or delete and possibly tag the issue 165 IssueID. See "help ids" for details on what constitutes an IssueID. 166 167 By default the issue will be deleted. You may set CloseStatusTag, 168 CloseMove, FitClosedDirName and/or ClosePreventDelete to change 169 how close/rm functions. 170 171 Note that closing an issue may cause other IssueIDs to change if 172 they do not have a stable id set (see "help ids", again.) 173 174 Also note that this removes the issue from the filesystem only. 175 To commit the removal you will need to execute "fit commit". 176 177 alias for close: rm 178 `) 179 case "find": 180 fmt.Printf("usage: " + os.Args[0] + " find tag <value1> [value2 ...]\n") 181 fmt.Printf("usage: " + os.Args[0] + " find status <value1> [value2 ...]\n") 182 fmt.Printf("usage: " + os.Args[0] + " find priority <value1> [value2 ...]\n") 183 fmt.Printf("usage: " + os.Args[0] + " find milestone <value1> [value2 ...]\n\n") 184 fmt.Printf( 185 `This will search all issues for multiple tags, statuses, priorities, or milestone. 186 The matching issues will be printed. 187 `) 188 case "purge": 189 fmt.Printf("usage: " + os.Args[0] + " purge\n\n") 190 fmt.Printf( 191 `This will delete any issues that are not currently tracked by 192 git or hg. 193 `) 194 case "twilio": 195 fmt.Printf("usage: " + os.Args[0] + " twilio\n\n") 196 fmt.Printf( 197 `This will send via twilio notifications of modified issues. 198 `) 199 case "commit", "save": 200 fmt.Printf("usage: " + os.Args[0] + " commit [--no-autoclose]\n\n") 201 fmt.Printf(`This will commit any new, modified, or removed issues to 202 git or hg. 203 204 Your working tree and staging area should be otherwise 205 unaffected by using this command. 206 207 If the --no-autoclose option is passed to commit, fit will 208 not include a "Closes #x" line for each issue imported from 209 "fit import --github." Otherwise, the commit message will 210 include the list of issues that were closed so that GitHub 211 will autoclose them when the changes are pushed upstream. 212 213 alias for commit: save 214 `) 215 case "env": 216 fmt.Printf("usage: " + os.Args[0] + " env\n\n") 217 fmt.Printf(`This will print the environment variables used by the command to stdout. 218 219 Use this command if you want to see settings what directory "fit create" is 220 using to store issues, or what editor will be invoked for a create/edit. 221 222 aliases for env: environment config settings 223 `) 224 225 case "pwd", "dir", "cwd": 226 fmt.Printf("usage: " + os.Args[0] + " pwd\n\n") 227 fmt.Printf( 228 `This will print the issue directory to stdout, 229 so you can use it as a subcommand for arguments to any 230 arbitrary shell commands. For example "cd $(fit pwd)" 231 232 aliases for pwd: dir cwd 233 `) 234 case "tag": 235 fmt.Printf("usage: " + os.Args[0] + " tag [--rm] <IssueID> <tag>...\n\n") 236 fmt.Printf(`This will tag the given IssueID with the tags 237 given as arguments. At least one tag is required. 238 239 Tags can be any string which would make a valid file name. 240 241 If the --rm option is provided before the IssueID, all tags provided will 242 be removed instead of added. 243 `) 244 case "roadmap": 245 fmt.Printf("usage: " + os.Args[0] + " roadmap [options]\n\n") 246 fmt.Printf( 247 `This will print a markdown formatted list of all open 248 issues, grouped by milestone. 249 250 Valid options are: 251 --simple Don't show anything other than the title in the output 252 --no-status Don't show the status of an issue 253 --no-priority Don't show the priority of an issue 254 --no-identifier Don't include the issue identifier of an issue 255 --tags Include the tags attached to an issue in it's output 256 257 --filter tag Only show issues matching tag 258 --filter tag1,tag2,etc Only show issues matching at least one of 259 the supplied tags 260 261 `) 262 case "id", "identifier": 263 fmt.Printf("usage: " + os.Args[0] + " id <IssueID> [--generate-id] <value>\n\n") 264 fmt.Printf( 265 `This will either set of retrieve the identifier for the issue 266 currently identified by IssueID. 267 268 If value is provided as an argument, the issue identifier will be set 269 to the value passed in. You should take care to ensure that any 270 identifier used has at least 1 non-numeric character, to ensure there 271 are no conflicts with automatically generated issue numbers used for 272 an issue that has no explicit identifier set. 273 274 If the --generate-id option is passed instead of a static value, a 275 short identifier will be generated derived from the issue's current 276 title (however, the identifier will remain unchanged if the issue's title 277 is changed.) 278 279 If only a IssueID is provided, the current identifier will be printed. 280 281 alias for id: identifier 282 `) 283 case "identifiers", "ids": 284 fmt.Printf( 285 `Issues can be referenced in 2 ways on the commandline, either by 286 an index of where the issue directory is located inside the issues 287 directory, or by an ID. "IssueID" can be either of these, 288 and %s will try to intelligently guess which your command is 289 referencing. 290 291 By default, no IDs are set for an issue. This means that 292 the issue number provided in "%s list" is an index into the directory 293 sorted by filesystem directory modified time. It is not completely 294 stable as issues are created, modified, and closed. The numbers are 295 easy to reference and remember in the short term. 296 297 If you have longer lasting issues that need a stable ID, 298 they can be created by "%s id <IssueID> <New ID>". 299 You can then use <New ID> to reference the issue. 300 301 There are no rules for what constitutes a valid id, but 302 you should try and ensure that they have at least 1 non-numeric 303 character so that they don't conflict with directory indexes. 304 305 If you just want an id but don't care what it is, you 306 can use "%s id <IssueID> --generate-id". 307 308 If there are no exact matches for the IssueID provided, %s commands will 309 also try and look up the issue by a substring match on all the valid 310 IDs in the system before giving up. 311 `, os.Args[0], os.Args[0], os.Args[0], os.Args[0], os.Args[0]) 312 case "version", "about", "--version", "-v": 313 fmt.Printf("usage: " + os.Args[0] + " version\n\n") 314 fmt.Printf( 315 `This will print information about the version of %s being 316 invoked. 317 318 aliases for version: about --version -v 319 `, os.Args[0]) 320 case "import": 321 fmt.Printf("usage: " + os.Args[0] + " import <--github|--be> <repo>\n\n") 322 fmt.Printf( 323 `This will read from github <user>/<repository> issues 324 or a local BugsEverywhere bug database to the issues/ directory. 325 326 Either "--github <user>/repo>" is required to import GitHub issues 327 or "--github <user>/<repo>/projects/<num>" to import a GitHub project 328 or "--be <path>" is required to import a local BugsEverywhere database. 329 GitHub projects require a configured GithubPersonalAccessToken value. 330 `) 331 //ids aliases: idlist idsassigned identifiers 332 //noids alias: noidentifiers 333 //tagslist aliases: tagsassigned tags 334 //notags 335 case "help", "--help", "-h": 336 fallthrough 337 default: 338 fmt.Printf("usage: " + os.Args[0] + ` help <command> 339 340 fit manages plain text issues with git or hg. 341 Use "fit help <command>" or "fit <command> help" for 342 more information about any command below. 343 `) 344 PrintVersion() 345 fmt.Printf(` 346 Commands for status/reading: 347 list List issues 348 find Search for tag of fields: id, status, priority, or milestone 349 tagslist List assigned tags 350 notags List issues without tags 351 ids List stable identifiers 352 noids List issues without stable identifiers 353 env Show settings used when invoked from this directory 354 pwd Print the issues directory 355 help Show this screen 356 version Print the version of this software 357 358 Commands for editing: 359 create Open new issue 360 edit Edit an issue 361 retitle Rename an issue 362 close Delete an issue 363 tag Tag an issue 364 id View or set a stable identifier 365 status View or set status 366 priority View or set priority 367 milestone View or set milestone 368 import Download from github or bugseverywhere repository 369 370 Commands for version control: 371 commit Commit any new, changed or deleted issues 372 purge Remove all issues not tracked 373 374 Commands for processing: 375 roadmap Print list of open issues sorted by milestone 376 377 aliases for help: --help -h 378 379 `) 380 } 381 // see issues/Config.go for comments when adding commands or configs 382 }