···1818The command needs to be run inside of the git repository (this is used to detect if the repository uses github or gitlab)
19192020```
2121-issurge [options] <file> [--] [<glab-args>...]
2121+issurge [options] <file> [--] [<submitter-args>...]
2222issurge --help
2323```
24242525-- **<glab-args>** contains arguments that will be passed as-is to every `glab` command.
2525+- **<submitter-args>** contains arguments that will be passed as-is to every `glab` (or `gh`) command.
26262727### Options
2828
+1-2
exemple/README.md
···88 '--dry-run': True,
99 '--help': False,
1010 '<file>': 'issues',
1111- '<glab-args>': []}
1111+ '<submitter-args>': []}
1212@me ~by:lubin Making children from ~by:lubin @me
1313~area:search Making children from ~by:lubin ~area:search @me
1414mettre un bouton "rechercher" ร la place de "voir Made mettre un bouton "rechercher" (...) ~by:lubin ~area:search @me
···189189" -a @me -l feature -l by:lubin
190190Would run glab issue new -t "faire un arbre des admins avec nom prรฉnom annรฉes AE" -d "" -a @me -l feature -l by:lubin
191191```
192192-
+4-3
issurge/main.py
···11#!/usr/bin/env python
22"""
33Usage:
44- issurge [options] <file> [--] [<glab-args>...]
44+ issurge [options] <file> [--] [<submitter-args>...]
55 issurge --help
6677-<glab-args> contains arguments that will be passed as-is to the end of all `glab' commands
77+<submitter-args> contains arguments that will be passed as-is to the end of all `glab' commands
8899Options:
1010 --dry-run Don't actually post the issues
···2727def run():
2828 opts = docopt(__doc__)
2929 os.environ["ISSURGE_DEBUG"] = "1" if opts["--debug"] else ""
3030+ os.environ["ISSURGE_DRY_RUN"] = "1" if opts["--dry-run"] else ""
30313132 debug(f"Running with options: {opts}")
3233 print("Submitting issues...")
3334 for issue in parse(Path(opts["<file>"]).read_text()):
3434- issue.submit()
3535+ issue.submit(opts["<submitter-args>"])
+24-21
issurge/parser.py
···11+import os
12import subprocess
22-from typing import Any, Iterable
33+from typing import Any, Iterable, NamedTuple
34from urllib.parse import urlparse
44-from rich import NamedTuple, print
5566-from issurge.utils import TAB, debug
66+from rich import print
77+88+from issurge.utils import NEWLINE, TAB, debug, debugging, dry_running
79810911class Node:
···485049515052class Issue(NamedTuple):
5151- _cli_options: dict[str, Any]
5253 title: str
5354 description: str
5455 labels: set[str]
···7879 subprocess.run(["git", "remote", "get-url", "origin"]).stdout.decode()
7980 )
8081 if remote_url.hostname == "github.com":
8181- self._github_submit()
8282+ self._github_submit(submitter_args)
8283 else:
8383- self._gitlab_submit()
8484+ self._gitlab_submit(submitter_args)
84858585- def _gitlab_submit(self):
8686+ def _gitlab_submit(self, submitter_args: list[str]):
8687 command = ["glab", "issue", "new"]
8788 if self.title:
8889 command += ["-t", self.title]
···9394 command += ["-l", l]
9495 if self.milestone:
9596 command += ["-m", self.milestone]
9696- command.extend(self._cli_options["<glab-args>"])
9797- if self._cli_options["--dry-run"] or self._cli_options["--debug"]:
9898- print(
9999- f"{'Would run' if self._cli_options['--dry-run'] else 'Running'} [white bold]{subprocess.list2cmdline(command)}[/]"
100100- )
101101- if not self._cli_options["--dry-run"]:
102102- subprocess.run(command)
9797+ command.extend(submitter_args)
9898+ self._run(command)
10399104104- def _github_submit(self):
100100+ def _github_submit(self, submitter_args: list[str]):
105101 command = ["gh", "issue", "new"]
106102 if self.title:
107103 command += ["-t", self.title]
···112108 command += ["-l", l]
113109 if self.milestone:
114110 command += ["-m", self.milestone]
115115- command.extend(self._cli_options["<glab-args>"])
116116- if self._cli_options["--dry-run"] or self._cli_options["--debug"]:
111111+ command.extend(submitter_args)
112112+ self._run(command)
113113+114114+ def _run(self, command):
115115+ if dry_running() or debugging():
117116 print(
118118- f"{'Would run' if self._cli_options['--dry-run'] else 'Running'} [white bold]{subprocess.list2cmdline(command)}[/]"
117117+ f"{'Would run' if dry_running() else 'Running'} [white bold]{subprocess.list2cmdline(command)}[/]"
119118 )
120120- if not self._cli_options["--dry-run"]:
121121- subprocess.run(command)
119119+ if not dry_running():
120120+ try:
121121+ subprocess.run(command, check=True, capture_output=True)
122122+ except subprocess.CalledProcessError as e:
123123+ print(
124124+ f"Calling [white bold]{e.cmd}[/] failed with code [white bold]{e.returncode}[/]:\n{NEWLINE.join(TAB + line for line in e.stderr.decode().splitlines())}"
125125+ )
122126123127 # The boolean is true if the issue expects a description (ending ':')
124128 @classmethod
···205209 labels=current_labels,
206210 assignees=current_assignees,
207211 milestone=current_milestone,
208208- _cli_options=cli_options,
209212 )
210213211214 if current_issue.title: