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
Rewrite of how input is parsed #215
Conversation
This is a major rewrite of how ultralist parses user input for all commands. Added structs: * Filter - the core struct that defines actions that can be done on a Todo or set of Todos * DateParser - a mini-library to parse dates from raw input * InputParser - parse user input and create a Filter struct from it Added methods: * CreateTodo - creates a todo from a Filter struct * EditTodo - edits a todo item based upon a Filter struct The core workflow is now: 1. User input is parsed via an InputParser, converted into a Filter struct 2. That Filter struct is then used to perform actions. Actions could be adding a todo, editing a todo, or listing todos + filtering the list. Other items: * Removed expand command (I'm not even 100% sure how it got there in the first place) * The app will no longer try to parse out IDs from input. Instead it will rely on Cobra to do that
Still WIP, needs date filtering
@stuartskelton I kind of rewrote everything, haha. Let me know what you think of the new architecture! |
I can see, this is going to be interesting to review. |
|
||
// ExpandTodo expands a todo. |
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.
expand is not something I used but came via #26
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.
I cant see anything obviously wrong with this. I think I would need to play around with it for a while.
ultralist/input_parser.go
Outdated
|
||
for _, word := range strings.Split(input, " ") { | ||
match := false | ||
r1, _ := regexp.Compile(`archived:.*$`) |
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.
I am assuming because we supply the string, and it doesn't come from outside, we feel safe there should be no errors.?
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.
input_parser.go
deals with input directly from the user, so there could be errors!
However, for this specific regex, I'm failing to see what might error out. The Parse
function already returns an error
so we could use it if need be, but I'd really need an example of a failing regex before we catch the error and return it.
The logic was not correct, and syncing lists was broken. Co-authored-by: Grant Ammons <gammons@gmail.com>
just realized that |
Thanks for the thorough review, @stuartskelton ! Going to merge this tomorrow unless you catch anything else. |
.todos.json in home dir would overwrite the .todos.json file in a deeper directory.
This is a major rewrite of how ultralist parses user input for all commands.
When interacting with ultralist, the core workflow is now:
Added structs:
Filter
- the core struct that defines actions that can be done on a Todo or set of TodosDateParser
- a mini-library to parse dates from raw inputInputParser
- parse user input and create a Filter struct from itTodoFilter
- filters an array ofTodo
structs based upon aFilter
Added methods:
CreateTodo
- creates a todo from a Filter structEditTodo
- edits a todo item based upon a Filter structRenamed:
Parser
is nowNoteParser
. This is a legacy class that is still needed in order to handle notes.Added functionality when listing todos:
duebefore
anddueafter
(example:duebefore:yesterday
)context:bob,mary
)-
in front (example:project:one,-two
)Other items:
app.go
will no longer try to parse out IDs from input. Instead it will rely on Cobra to do that.This PR changes the syntax for adding, listing, and manipulating todos.. But, on the plus side, this PR lays out a consistent format. Essentially, all interactions follow a
item:val
format. Some examples:Adding a todo
Editing a todo
Listing todos