Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions docs/git-draft.1.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ IMPORTANT: `git-draft` is WIP.
== Synopsis

[verse]
git draft [options] [--new] [--accept... | --no-accept] [--bot BOT]
[--edit] [TEMPLATE [VARIABLE...] | -]
git draft [options] [--new] [--accept... | --no-accept] [--bot BOT] [--edit]
[TEMPLATE [VARIABLE...] | -]
git draft [options] --quit
git draft [options] --events [REF]
git draft [options] --templates [--json | [--edit] TEMPLATE]
git draft [options] --list-events [DRAFT]
git draft [options] --list-templates
git draft [options] --show-template [--edit] TEMPLATE


== Description
Expand Down Expand Up @@ -56,10 +57,14 @@ By default, changes are not merged - keeping the working directory untouched.
A different default can be set in the configuration file.
When doing so, the `--no-accept` flag can be used to disable merging at CLI invocation time.

--batch::
Disable interactive feedback.
If a bot needs more information, its question will be persisted and displayed when creating the next draft.

-b BOT::
--bot=BOT::
Bot name.
Defaults to the first bot defined in the configuration.
Set bot name.
The default is to use the first bot defined in the configuration.

-e::
--edit::
Expand All @@ -77,6 +82,10 @@ Show help message and exit.
--json::
Use JSON output.

-E::
--list-events::
Display all events corresponding to a draft.

--log-path::
Show log path and exit.

Expand All @@ -92,10 +101,13 @@ Go back to the draft's origin branch, keeping the working directory's current st
This will delete the draft branch and its upstream.
Generated commits and the draft branch's final state remain available via `refs/drafts`.

-S::
--show-template::
Display the corresponding template's contents or, if the `--edit` option is set, open an interactive editor with its contents.

-T::
--templates::
With no argument, lists available templates.
With an template name argument, displays the corresponding template's contents or, if the `--edit` option is set, opens an interactive editor with its contents.
--list-templates::
Lists available templates.

--version::
Show version and exit.
Expand Down
36 changes: 19 additions & 17 deletions src/git_draft/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def callback(

add_command("new", help="create a new draft from a prompt")
add_command("quit", help="return to original branch")
add_command("events", help="list events")
add_command("templates", short="T", help="show template information")
add_command("list-events", short="E", help="list events")
add_command("show-template", short="S", help="show template information")
add_command("list-templates", short="T", help="list available templates")

parser.add_option(
"-a",
Expand Down Expand Up @@ -215,26 +216,27 @@ async def run() -> None: # noqa: PLR0912 PLR0915
drafter.quit_folio()
case "quit":
drafter.quit_folio()
case "events":
case "list-events":
draft_id = args[0] if args else None
for elem in drafter.list_draft_events(draft_id):
print(elem)
case "templates":
if args:
name = args[0]
meta = find_prompt_metadata(name)
if opts.edit:
if meta:
edit(path=meta.local_path(), text=meta.source())
else:
edit(path=PromptMetadata.local_path_for(name))
case "show-template":
if len(args) != 1:
raise ValueError("Expected exactly one argument")
name = args[0]
meta = find_prompt_metadata(name)
if opts.edit:
if meta:
edit(path=meta.local_path(), text=meta.source())
else:
if not meta:
raise ValueError(f"No template named {name!r}")
print(meta.source())
edit(path=PromptMetadata.local_path_for(name))
else:
table = templates_table()
print(table.to_json() if opts.json else table)
if not meta:
raise ValueError(f"No template named {name!r}")
print(meta.source())
case "list-templates":
table = templates_table()
print(table.to_json() if opts.json else table)
case _:
raise UnreachableError()

Expand Down