this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

✨ Add an interactive one-shot mode (Closes #1)

+53 -3
+16
README.md
··· 67 67 68 68 Another issue. 69 69 ``` 70 + 71 + ### One-shot mode 72 + 73 + You can also create a single issue directly from the command line with `issurge new`. 74 + 75 + If you end the line with `:`, issurge will prompt you for more lines. 76 + 77 + ```sh-session 78 + $ issurge new ~tag1 a tag right there @me : 79 + Please enter a description for the issue (submit 2 empty lines to finish): 80 + > Basically allow users to enter an issue fragment directly on the command line with a subcommand, and if it expects a description, prompt for it 81 + > 82 + > 83 + Submitting add an interactive "one-shot" (...) ~enhancement @me [...] 84 + Running gh issue new -t "add an interactive \"one-shot\" mode" -b "Basically allow users to enter an issue fragment directly on the command line with a subcommand, and if it expects a description, prompt for it" -a @me -l enhancement 85 + ```
+25
issurge/interactive.py
··· 1 + from .parser import Issue, parse 2 + 3 + 4 + def create_issue(words: str) -> Issue: 5 + issue, expects_description = Issue.parse(words) 6 + if expects_description: 7 + print( 8 + "Please enter a description for the issue (submit 2 empty lines to finish):" 9 + ) 10 + description = "" 11 + next_empty_is_finish = False 12 + while True: 13 + line = input("> ") 14 + if line == "": 15 + if next_empty_is_finish: 16 + break 17 + next_empty_is_finish = True 18 + else: 19 + next_empty_is_finish = False 20 + 21 + description += line + "\n" 22 + 23 + issue = Issue(**(issue._asdict() | {"description": description.strip()})) 24 + 25 + return issue
+12 -3
issurge/main.py
··· 1 1 #!/usr/bin/env python 2 2 """ 3 3 Usage: 4 - issurge [options] <file> [--] [<submitter-args>...] 4 + issurge [options] new <words>... 5 + issurge [options] <file> [--] [<submitter-args>...] 5 6 issurge --help 6 7 8 + issurge new <words>... acts like echo <words>... | issurge /dev/stdin, but also asks for a description if the issue ends with `:'. 9 + 7 10 <submitter-args> contains arguments that will be passed as-is to the end of all `glab' commands 8 11 9 12 Options: ··· 18 21 19 22 from issurge.parser import parse 20 23 from issurge.utils import debug 24 + from issurge import interactive 21 25 22 26 23 27 def run(opts=None): ··· 26 30 os.environ["ISSURGE_DRY_RUN"] = "1" if opts["--dry-run"] else "" 27 31 28 32 debug(f"Running with options: {opts}") 29 - print("Submitting issues...") 30 - for issue in parse(Path(opts["<file>"]).read_text()): 33 + if opts["new"]: 34 + issue = interactive.create_issue(" ".join(opts["<words>"])) 35 + debug(f"Submitting {issue.display()}") 31 36 issue.submit(opts["<submitter-args>"]) 37 + else: 38 + print("Submitting issues...") 39 + for issue in parse(Path(opts["<file>"]).read_text()): 40 + issue.submit(opts["<submitter-args>"])