better dev command
This commit is contained in:
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
## Dev helper (`bin/dev`)
|
## Dev helper (`bin/dev`)
|
||||||
|
|
||||||
`bin/dev` (on PATH via direnv as `dev`) wraps common project tasks. Run `dev bash-completions` to list commands.
|
`bin/dev` wraps common project tasks. Run `bin/dev bash-completions` to list commands.
|
||||||
|
|
||||||
### Creating issues
|
### Creating issues
|
||||||
|
|
||||||
Use `dev issue` to create Gitea issues instead of calling the API or `tea` directly:
|
Use `bin/dev issue` to create Gitea issues instead of calling the API or `tea` directly:
|
||||||
|
|
||||||
```
|
```
|
||||||
dev issue "<title>" [-b "<body>"] [-l <label>]... [-a <user>]... [--open]
|
bin/dev issue "<title>" [-b "<body>"] [-l <label>]... [-a <user>]... [--open]
|
||||||
```
|
```
|
||||||
|
|
||||||
- Labels are repo label names (`bug`, `enhancement`, `question`, ...).
|
- Labels are repo label names (`bug`, `enhancement`, `question`, ...).
|
||||||
|
|||||||
@@ -27,6 +27,9 @@ class DevHelper:
|
|||||||
# Core logic
|
# Core logic
|
||||||
def call(self, *args, **kwargs):
|
def call(self, *args, **kwargs):
|
||||||
if not args:
|
if not args:
|
||||||
|
print("Usage: dev <command> [args...]\n\nCommands:")
|
||||||
|
for command in self._commands():
|
||||||
|
print(f" {command}")
|
||||||
return
|
return
|
||||||
|
|
||||||
command, rest = args[0], args[1:]
|
command, rest = args[0], args[1:]
|
||||||
@@ -136,14 +139,16 @@ class DevHelper:
|
|||||||
raise NotImplementedError(f"Not implemented for platform {sys.platform}")
|
raise NotImplementedError(f"Not implemented for platform {sys.platform}")
|
||||||
|
|
||||||
def bash_completions(self, *args, **kwargs):
|
def bash_completions(self, *args, **kwargs):
|
||||||
completions = sorted(
|
print(" ".join(self._commands()))
|
||||||
|
|
||||||
|
# Private helpers
|
||||||
|
def _commands(self):
|
||||||
|
return sorted(
|
||||||
METHOD_TO_COMMAND.get(name, name)
|
METHOD_TO_COMMAND.get(name, name)
|
||||||
for name in vars(DevHelper)
|
for name in vars(DevHelper)
|
||||||
if not name.startswith("_") and name != "call" and callable(getattr(DevHelper, name))
|
if not name.startswith("_") and name != "call" and callable(getattr(DevHelper, name))
|
||||||
)
|
)
|
||||||
print(" ".join(completions))
|
|
||||||
|
|
||||||
# Private helpers
|
|
||||||
def _parse_issue_url(self, url):
|
def _parse_issue_url(self, url):
|
||||||
match = re.match(r"^(https?://[^/]+)/([^/]+)/([^/]+)/issues/(\d+)", url)
|
match = re.match(r"^(https?://[^/]+)/([^/]+)/([^/]+)/issues/(\d+)", url)
|
||||||
if match is None:
|
if match is None:
|
||||||
|
|||||||
Reference in New Issue
Block a user