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

View File

@ -23,7 +23,7 @@
::
=/ pax /(scot %p our)/[desk]/(scot cas)/story
?: !.^(? %cu pax)
~& >> "Error: desk {<desk>} does not exist."
~& >> "Error: No story file found. Please use |story-init to create one."
helm-pass+[%d %noop ~]
=/ tale=story .^(story %cx /(scot %p our)/[desk]/(scot %da now)/story)
=. 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
=/ cas r.bec :: use case from beak
=/ 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.' ~]
=/ tale=story .^(story %cx pax)
=/ story-to-mime .^($-(story mime) %cf /(scot %p our)/[desk]/(scot cas)/story/mime)

View File

@ -12,6 +12,8 @@
=/ our p.bec
=? desk =(*^desk desk) q.bec :: use current desk if user didn't provide
=/ 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
?: !.^(? %cu pax) tang+['Error: No story file found. Please use |story-init to create one.' ~]
=/ tale .^(story %cx pax)