-
Notifications
You must be signed in to change notification settings - Fork 679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Always ask for the note title when creating from template #645
Conversation
I think I understand the use case you are describing, I am wondering if the approach we should take could be along the lines of:
in this way, if the I believe the issue you linked to would also be addressed by this flow. What do you think? p.s. completely unrelated, but I really like the PR template you use, I would like to make it the standard PR for Foam |
In the future, we'll make this conditional on whether the template provides the filepath to use in its metadata block
@riccardoferretti (I hope I've interpreted it correctly 🤞) I've tried to map out the behaviour more clearly so that we can be sure that we are talking about the same things. There are 5 cases, which I have labeled A-E. I believe that the only difference between the behaviours is in Case D. Current behaviour on
|
filepath doesn't exist |
filepath exists, but doesn't contain $FOAM_TITLE |
filepath exists, and contains $FOAM_TITLE |
|
---|---|---|---|
$FOAM_TITLE in the template |
A: 1 step: Ask for title | B: 1 step: Ask for title | C: 1 step: Ask for title |
$FOAM_TITLE not in the template |
D: 0 steps: New Note.md created |
E: 0 steps: note created according to filepath |
N/A, if $FOAM_TITLE is in the filepath, it is in the template |
Current behaviour on this PR
This PR changes the behaviour of Case D to ask for the title. This is preferred over the existing master
-branch behaviour since always having to rename New Note.md
to the desired name (outside of the note creation flow) is tiresome.
filepath doesn't exist |
filepath exists, but doesn't contain $FOAM_TITLE |
filepath exists, and contains $FOAM_TITLE |
|
---|---|---|---|
$FOAM_TITLE in the template |
A: 1 step: Ask for title | B: 1 step: Ask for title | C: 1 step: Ask for title |
$FOAM_TITLE not in the template |
D: 1 step: Ask for title | E: 0 steps: note created according to filepath |
N/A, if $FOAM_TITLE is in the filepath, it is in the template |
Behaviour described in comment proposal
If I'm parsing it correctly, Case D is once again the only thing that changes:
filepath doesn't exist |
filepath exists, but doesn't contain $FOAM_TITLE |
filepath exists, and contains $FOAM_TITLE |
|
---|---|---|---|
$FOAM_TITLE in the template |
A: 1 step: Ask for title | B: 1 step: Ask for title | C: 1 step: Ask for title |
$FOAM_TITLE not in the template |
D: 1 step: Ask for path (Showing <current_dir>/New Note.md ) |
E: 0 steps: note created according to filepath |
N/A, if $FOAM_TITLE is in the filepath, it is in the template |
we skip one step by only asking for the filepath
Both this PR and the comment proposal have the same number of steps to create a note. No steps are skipped?
What do you think?
I think the only difference between these is what to ask the user for when a template does not include $FOAM_TITLE
?:
- In this PR, it asks the user for the title of the note
- In the comment proposal, it asks the user for the path of the note
I prefer asking the user for the title over the path, for two reasons:
- Consistency: In this PR,
Foam: Create New Note
only ever asks for a single thing in all cases: the title- In the comment proposal, Case D will ask for a path, unlike Cases A-C which ask for a title
- Aesthetic: In general, I'd rather that I never have to look at paths. Titles look cleaner / nicer.
- If you need control over the path, you can specify a
filepath
(once implemented) or fall back to useFoam: Create New Note From Template
- If you need control over the path, you can specify a
hi @movermeyer, in your example above:
There are two inputs required from the user, wasn't this the flow you were thinking of? |
@riccardoferretti That example in the PR description is for I think your comment describes the current behaviour of Current behaviour of
So currently, there are at most 3 steps to |
oops, my wires crossed on that one, you are right |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
What are you trying to accomplish?
In order to create a note from a template you need two things:
In cases where the template doesn't explicitly specify the path using the metadata syntax (i.e. all current templates since the metadata syntax isn't implemented yet), we'll add
$FOAM_TITLE
to the list of variables to resolve, and use it as the filepath.This will prompt the user for a title as they (reasonably) expect it to.
Then in the future when the template metadata block contains an explicit override of the filepath, we will stop adding
$FOAM_TITLE
, and whether or not the user gets prompted will depend on the contents of thefilepath
metadata.Fixes #640
Ref: #640 (comment)
What approach did you choose and why?
I've added
FOAM_TITLE
unconditionally to the list of variables to resolve, resulting inFoam: Create New Note
always asking for a note's title.In the future, we'll make this conditional on whether the template provides the filepath to use in its metadata block.
What should reviewers focus on?
Are there cases you could imagine where someone would not want it to prompt for a title, besides the future scenario where the
filepath
metadata is provided in the template?I'm writing this very early in the morning with little sleep. I may be forgetting some case???
What doesn't change with this PR?
Note: This PR does not change the behaviour of
Foam: Create New Note From Template
.In cases where the template does not reference
${FOAM_TITLE}
, the user will still not be prompted to enter a title.This works, since in
Foam: Create New Note From Template
there is a separate step where they fill in the filepath they desire. If we were to always resolve${FOAM_TITLE}
, it could make this command take longer than necessary, especially in cases where their desired filepath does not match the desired title:Example of where always asking for title in
Foam: Create New Note From Template
would be a worse UXFoam: Create New Note From Template
; selects an empty template.<dir>/On the Origin of Species.md
<dir>/draft-1.md
The user never wanted the title to be reflected in the filepath, so there was no need to prompt them.
It's fine to always prompt them in the
Foam: Create New Note
case, since that command is opinionated in order to have the most streamlined command for the most common use case.Foam: Create New Note From Template
is slower, but less opinionated, and more flexible/powerful.