story: generators: add desk existence everywhere

This commit is contained in:
Yaseen 2022-02-21 22:13:15 -05:00
parent 4eb7e623cd
commit 38a2e9d74a
5 changed files with 16 additions and 11 deletions

View File

@ -9,6 +9,9 @@
== ==
=/ our p.bec =/ our p.bec
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide =? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
~& >> "Error: desk {<desk>} does not exist."
helm-pass+[%d %noop ~]
=/ existing-story .^(? %cu /(scot %p our)/[desk]/(scot %da now)/story) =/ existing-story .^(? %cu /(scot %p our)/[desk]/(scot %da now)/story)
?: ?&(existing-story !overwrite) ?: ?&(existing-story !overwrite)
~& >> "Error: /{(trip (slav %tas desk))}/story already exists. Set the optional parameter `overwrite` to `%.y` to forcibly overwrite." ~& >> "Error: /{(trip (slav %tas desk))}/story already exists. Set the optional parameter `overwrite` to `%.y` to forcibly overwrite."

View File

@ -5,16 +5,14 @@
/- *story /- *story
:- %say :- %say
|= $: [now=@da eny=@uvJ bec=beak] |= $: [now=@da eny=@uvJ bec=beak]
[[=desk ~] cas=cash prz=prose ~] [[cas=cash ~] =desk prz=prose ~]
== ==
:: =/ our p.bec
:: XX: story set and story init both have desk and case as optional. =? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
:: however, it seems a bit odd to allow both optional here =? cas =(*case cas) r.bec :: use case from beak if cas not provided
:: since we're dealing with a more hazardous operation. ?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
:: should we allow a bare `|story-remove` to remove the last commit message on the current desk? ~& >> "Error: desk {<desk>} does not exist."
:: leaning towards no, and potentially even making the case non-optional helm-pass+[%d %noop ~]
=/ our p.bec
=? cas =(*case cas) r.bec :: use case from beak if cas not provided
?: !.^(? %cs /(scot %p our)/[desk]/(scot cas)/case) ?: !.^(? %cs /(scot %p our)/[desk]/(scot cas)/case)
~& >> "Error: invalid case {<cas>} provided" ~& >> "Error: invalid case {<cas>} provided"
helm-pass+[%d %noop ~] helm-pass+[%d %noop ~]
@ -25,7 +23,7 @@
:: ::
=/ pax /(scot %p our)/[desk]/(scot %da now)/story =/ pax /(scot %p our)/[desk]/(scot %da now)/story
?: !.^(? %cu pax) ?: !.^(? %cu pax)
~& >> "Error: desk {<desk>} does not exist." ~& >> "Error: No story file found. Please use |story-init to create one."
helm-pass+[%d %noop ~] helm-pass+[%d %noop ~]
=/ tale=story .^(story %cx pax) =/ tale=story .^(story %cx pax)
=. tale =. tale

View File

@ -23,7 +23,7 @@
:: ::
=/ pax /(scot %p our)/[desk]/(scot cas)/story =/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !.^(? %cu pax) ?: !.^(? %cu pax)
~& >> "Error: desk {<desk>} does not exist." ~& >> "Error: No story file found. Please use |story-init to create one."
helm-pass+[%d %noop ~] helm-pass+[%d %noop ~]
=/ tale=story .^(story %cx /(scot %p our)/[desk]/(scot %da now)/story) =/ tale=story .^(story %cx /(scot %p our)/[desk]/(scot %da now)/story)
=. tale (~(put ju tale) tak prose) =. tale (~(put ju tale) tak prose)

View File

@ -11,6 +11,8 @@
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide =? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
=/ cas r.bec :: use case from beak =/ cas r.bec :: use case from beak
=/ pax /(scot %p our)/[desk]/(scot cas)/story =/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
tang+[leaf+"Error: desk {<desk>} does not exist." ~]
?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~] ?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ tale=story .^(story %cx pax) =/ tale=story .^(story %cx pax)
=/ story-to-mime .^($-(story mime) %cf /(scot %p our)/[desk]/(scot cas)/story/mime) =/ story-to-mime .^($-(story mime) %cf /(scot %p our)/[desk]/(scot cas)/story/mime)

View File

@ -12,6 +12,8 @@
=/ our p.bec =/ our p.bec
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide =? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
=/ cas=case r.bec :: use case from beak =/ cas=case r.bec :: use case from beak
?: !(~(has in .^((set ^desk) %cd /(scot %p our)/$/(scot %da now))) desk)
tang+[leaf+"Error: desk {<desk>} does not exist." ~]
=/ pax /(scot %p our)/[desk]/(scot cas)/story =/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~] ?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ tale .^(story %cx pax) =/ tale .^(story %cx pax)