Skip to content
This repository was archived by the owner on Jul 25, 2023. It is now read-only.

Feat/migrate to clap #17

Merged
merged 13 commits into from
Oct 18, 2022
Merged

Feat/migrate to clap #17

merged 13 commits into from
Oct 18, 2022

Conversation

xNaCly
Copy link
Owner

@xNaCly xNaCly commented Oct 17, 2022

Migration to clap

fixes: #14
fixes: #3
improves: #12
lays foundation for: #16

Changes:

  • migrated to clap:

    Usage: opus <COMMAND>
    
    Commands:
      add     create a new task [aliases: a]
      delete  delete a task with the given id [aliases: del, d]
      clear   remove all tasks from the database
      finish  mark the task with the given id as finished [aliases: fin, f]
      list    list tasks matching the given query [aliases: ls, l]
      export  export all tasks
      help    Print this message or the help of the given subcommand(s)
    
    Options:
      -h, --help     Print help information
      -V, --version  Print version information
    
  • added --finished flag to opus ls:

    list tasks matching the given query
    
    Usage: opus list [OPTIONS] [QUERY]
    
    Arguments:
      [QUERY]  
    
    Options:
      -f, --finished  displays tasks marked as finished
      -h, --help      Print help information
      -V, --version   Print version information
    
  • reworked opus export to provide a better interface:

    • before
      # exports all tasks in the data.json file
      opus export json data
      # export all tasks in the mycsvfile.csv file
      opus export csv mycsvfile
      # data.tsv
      opus export tsv data
    • after
      # exports all tasks in the data.json file
      opus export --format="json" --output="data.json"
      # export all tasks in the data.csv file
      opus export --format="csv" --output="data.csv"
      # export all tasks in the data.tsv file
      opus export --format="tsv" --output="data.csv"
  • switched from specifing a tasks priority with symbols , to numbers prefixed with .

    • before:
      # add a new task with the following properties:
      # title: review and merge pr 5
      # due: @tomorrow
      # tag: #github
      # priority: 3
      opus add "review and merge pr 5 @tomorrow #github ,,,"
    • after:
      # add a new task with the following properties:
      # title: review and merge pr 5
      # due: @tomorrow
      # tag: #github
      # priority: 3
      opus add "review and merge pr 5 @tomorrow #github .3"
  • rewrote tests and removed everything regarding the self made args parser

  • improved task displaying:

    • before:
      [2]: 'update excel sheet' (2022-10-13) #work [,,,]
      
    • after:
      [2]: 'update excel sheet' (2022-10-13) #work .3 FINISHED
      

xNaCly added 12 commits October 17, 2022 14:35
migrated opus list to clap logic, implemented displaying finished tasks via the --finished flag
i got stuff to do #work .5 @2022-10-17

translates to:

[src/tests.rs:291] &t = Task {
    id: None,
    title: "i got stuff to do",
    tag: "#work",
    priority: 5,
    due: "2022-10-17",
    finished: false,
}

- this commit changes the behaviour of specifing the priority by commatas to the new implementation which consists of prefixing the prio with a '.': Priority of 5 is to be written as '.5'
- updated querying by priority in opus list
- add a test for parsing
- update usage
- panic if task title is empty
- FINISHED information now appears behind a tasks content if its marked as finished
- priority changes are now reflected in printing tasks:

  before:
   [2]: 'update excel sheet' (2022-10-13) #work [,,,]
   after:
   [2]: 'update excel sheet' (2022-10-13) #work .3 FINISHED
- implement all commands
  - clear
  - delete
  - finish
  - export
- remove unused types
- remove old logic
- added changes suggested by clippy
- update usage
Copy link
Contributor

@hlxid hlxid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here are a few code quality related things that you may want to look at.
Functionality-wise this looks good to me.

- replace whole if statement with logical 'or' / '||'
- add ExportType::from(&str)
- update Task::from(&str)
- add Task.compare
- add makro to extract crate description
Copy link
Contributor

@hlxid hlxid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@xNaCly xNaCly merged commit abff05a into master Oct 18, 2022
@xNaCly xNaCly deleted the feat/migrate-to-clap branch October 18, 2022 07:05
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Migrate to clap Display finished tasks
2 participants