@@ -32,7 +32,7 @@ def new_parser() -> optparse.OptionParser:
3232 parser .disable_interspersed_args ()
3333
3434 parser .add_option (
35- "--log" ,
35+ "--log-path " ,
3636 help = "show log path and exit" ,
3737 action = "store_true" ,
3838 )
@@ -60,21 +60,21 @@ def callback(
6060 ** kwargs ,
6161 )
6262
63- add_command ("finalize " , help = "apply current draft to original branch " )
64- add_command ("generate " , help = "create or update draft from a prompt " )
65- add_command ("show- templates" , short = "T" , help = "show template information" )
63+ add_command ("new " , help = "create a new draft from a prompt " )
64+ add_command ("quit " , help = "return to original branch " )
65+ add_command ("templates" , short = "T" , help = "show template information" )
6666
6767 parser .add_option (
6868 "-a" ,
6969 "--accept" ,
70- help = "accept draft, may be repeated" ,
70+ help = "merge draft, may be repeated" ,
7171 action = "count" ,
7272 )
7373 parser .add_option (
7474 "-b" ,
7575 "--bot" ,
7676 dest = "bot" ,
77- help = "bot name" ,
77+ help = "AI bot name" ,
7878 )
7979 parser .add_option (
8080 "-e" ,
@@ -91,7 +91,7 @@ def callback(
9191
9292 parser .add_option (
9393 "--no-accept" ,
94- help = "do not update worktree from draft" ,
94+ help = "do not merge draft" ,
9595 dest = "accept" ,
9696 action = "store_const" ,
9797 const = 0 ,
@@ -106,16 +106,18 @@ class Accept(enum.Enum):
106106 MANUAL = 0
107107 MERGE = enum .auto ()
108108 MERGE_THEIRS = enum .auto ()
109- FINALIZE = enum .auto ()
109+ MERGE_THEN_QUIT = enum .auto ()
110110
111111 def merge_strategy (self ) -> DraftMergeStrategy | None :
112- match self . value :
112+ match self :
113113 case Accept .MANUAL :
114114 return None
115115 case Accept .MERGE :
116116 return "ignore-all-space"
117- case _ :
117+ case Accept . MERGE_THEIRS | Accept . MERGE_THEN_QUIT :
118118 return "theirs"
119+ case _:
120+ raise UnreachableError ()
119121
120122
121123class ToolPrinter (ToolVisitor ):
@@ -175,10 +177,15 @@ def main() -> None: # noqa: PLR0912 PLR0915
175177 (opts , args ) = new_parser ().parse_args ()
176178
177179 log_path = ensure_state_home () / "log"
178- if opts .log :
180+ if opts .log_path :
179181 print (log_path )
180182 return
181- logging .basicConfig (level = config .log_level , filename = str (log_path ))
183+ logging .basicConfig (
184+ level = config .log_level ,
185+ filename = str (log_path ),
186+ format = "%(asctime)s %(name)-12s %(levelname)-8s %(message)s" ,
187+ datefmt = "%m-%d %H:%M" ,
188+ )
182189
183190 repo = Repo .enclosing (Path (opts .root ) if opts .root else Path .cwd ())
184191 drafter = Drafter .create (repo , Store .persistent ())
@@ -210,7 +217,7 @@ def main() -> None: # noqa: PLR0912 PLR0915
210217 prompt = sys .stdin .read ()
211218
212219 accept = Accept (opts .accept or 0 )
213- drafter .generate_draft (
220+ draft = drafter .generate_draft (
214221 prompt ,
215222 bot ,
216223 prompt_transform = open_editor if editable else None ,
@@ -219,18 +226,18 @@ def main() -> None: # noqa: PLR0912 PLR0915
219226 )
220227 match accept :
221228 case Accept .MANUAL :
222- print ("Generated draft." )
229+ print (f "Generated draft. [ref= { draft . ref } ] ." )
223230 case Accept .MERGE | Accept .MERGE_THEIRS :
224- print ("Merged draft." )
225- case Accept .FINALIZE :
226- drafter .finalize_folio ()
227- print ("Finalized draft." )
231+ print (f"Generated and merged draft. [ref= { draft . ref } ] " )
232+ case Accept .MERGE_THEN_QUIT :
233+ drafter .quit_folio ()
234+ print (f"Generated and applied draft. [ref= { draft . ref } ] " )
228235 case _:
229236 raise UnreachableError ()
230- case "finalize " :
231- drafter .finalize_folio ()
232- print ("Finalized draft folio ." )
233- case "show- templates" :
237+ case "quit " :
238+ drafter .quit_folio ()
239+ print ("Applied draft." )
240+ case "templates" :
234241 if args :
235242 name = args [0 ]
236243 tpl = find_template (name )
0 commit comments