Draft: Autocomplete tests #40
No reviewers
Labels
No Label
bug
config
feature
formatters
idea
new-command
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: categulario/tiempo-rs#40
Loading…
Reference in New Issue
No description provided.
Delete Branch "dev-autocomplete"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I created tests for autocomplete and a new type of error (InvalidAutocompleteFormatter).
Now I wait to known all my mistakes xD
Something that we need to discuss is the matching mechanism. I think the matching must be by prefix instead of by substring. This I think creates an easier mental model for the user as to what she needs to type and what she can omit in order to invoke the desired formatter. What do you think?
Secon thing is: I don't see necessary to create a new error because the current error for when a formatter is not found is quite explicit. Maybe we can extend the error message to suggest that no formatter with the given name or prefix was found.
Ok, a new error is needed but for the case where the prefix is ambiguous, like if the user wrote
t d -f a
and she has two custom formatters:accounting
andaverage
. In this case the error should be clear enough about the ambiguity.use
assert_eq!
macro to test that the formatter found is the correct onesimilar to the above, use the
matches!
macro to check that it is the expected variant.this function will be used by production code, it should be outside of the
tests
submodule.in the end we'll probably use some macro trick to get this list from the Formatter enum itself.
why cannot match a formatter with only one character?
Do you mean
FormatterNotFound
Error? Because I decided to create a new one so I don't have to deal withpaths
andconfig_at
xDOh, ok, so I guess it won't just give the first match as it is implemented right now, but an error, right?
So
assert_eq!
ormatches!
or both (can it be both?)?To avoid ambiguity. But I remember now that you like unreadable shorthands like
t -f t
so I am gonna remove that constraint xDmarked this merge request as draft
Similar approach but I used strum for
Formatter::VARIANTS
instead of a macro.mentioned in commit
70c9aa9355
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in version 2 of the diff
changed this line in version 2 of the diff
added 1 commit
70c9aa93
- Fix some issues from !8Compare with previous version
this function doesn't access
&self
or variants and it already belongs to an appropriate namespace, therefore it can live outside of any impl block just by itself.Ok, I can do that. But this makes me think if it is better idea to refactor
from_str
so it tries to do before the autocomplete and, therefore, there is noautocomplete
fn needed. The main diff is that in case that there is no match during the autocomplete attempt,&str
will the treated as a custom formatter, instead of throwing an error. What do you think?Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Forgejo.