Skip to content
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

Merged
merged 20 commits into from Sep 10, 2020
Merged

Rewrite of how input is parsed #215

merged 20 commits into from Sep 10, 2020

Conversation

gammons
Copy link
Owner

@gammons gammons commented Aug 22, 2020

This is a major rewrite of how ultralist parses user input for all commands.

When interacting with ultralist, 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.

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
  • TodoFilter - filters an array of Todo structs based upon a Filter

Added methods:

  • CreateTodo - creates a todo from a Filter struct
  • EditTodo - edits a todo item based upon a Filter struct

Renamed:

  • Parser is now NoteParser. This is a legacy class that is still needed in order to handle notes.

Added functionality when listing todos:

  • There are now options for duebefore and dueafter (example: duebefore:yesterday)
  • You can now filter on multiple, comma-separated values for projects, contexts and statuses (example: context:bob,mary)
  • There is now an exclusion filter for projects, contexts, and statuses by using - in front (example: project:one,-two)

Other items:

  • Removed expand command (I'm not even 100% sure how it got there in the first place)
  • 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

ultralist a do something due:tod status:next

Editing a todo

ultralist e 5 priority:true status:now due:tom

Listing todos

ultralist l status:now,next,-later
ultralist l duebefore:tod

Grant Ammons added 5 commits August 22, 2020 06:43
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
@gammons gammons changed the title New parsers Rewrite of how input is parsed Aug 26, 2020
@gammons gammons mentioned this pull request Aug 26, 2020
@gammons gammons marked this pull request as ready for review August 27, 2020 10:27
@gammons
Copy link
Owner Author

gammons commented Aug 27, 2020

@stuartskelton I kind of rewrote everything, haha. Let me know what you think of the new architecture!

@stuartskelton
Copy link
Contributor

@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.
Copy link
Contributor

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

Copy link
Contributor

@stuartskelton stuartskelton left a 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/app.go Show resolved Hide resolved
ultralist/create_todo.go Outdated Show resolved Hide resolved
ultralist/date_parser.go Outdated Show resolved Hide resolved
ultralist/date_parser.go Show resolved Hide resolved

for _, word := range strings.Split(input, " ") {
match := false
r1, _ := regexp.Compile(`archived:.*$`)
Copy link
Contributor

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.?

Copy link
Owner Author

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.

ultralist/input_parser.go Outdated Show resolved Hide resolved
ultralist/input_parser.go Outdated Show resolved Hide resolved
Grant Ammons and others added 2 commits August 28, 2020 06:31
The logic was not correct, and syncing lists was broken.

Co-authored-by: Grant Ammons <gammons@gmail.com>
@gammons
Copy link
Owner Author

gammons commented Aug 28, 2020

just realized that due:agenda is broke. will fix tomorrow

@gammons
Copy link
Owner Author

gammons commented Sep 1, 2020

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.
@gammons gammons merged commit 5e10ff5 into main Sep 10, 2020
@gammons gammons deleted the new-parsers branch September 10, 2020 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants