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

Add possibility in opus list to sort tasks #16

Closed
hlxid opened this issue Oct 12, 2022 · 1 comment · Fixed by #19
Closed

Add possibility in opus list to sort tasks #16

hlxid opened this issue Oct 12, 2022 · 1 comment · Fixed by #19

Comments

@hlxid
Copy link
Contributor

hlxid commented Oct 12, 2022

Currently, tasks are output in the order that they are inside the SQLite database.
It would be pretty handy to be able to sort the displayed tasks by priority, due date or id.
This could be done with a command line flag, e.g. --sort priority (maybe with short forms like --sort prio).

@hlxid hlxid changed the title Add option to opus list to sort tasks Add possibility in opus list to sort tasks Oct 12, 2022
@xNaCly
Copy link
Owner

xNaCly commented Oct 13, 2022

Id say this change can only be done after #14 is finished, due to the complex way argument parsing is currently done.

Will add this to the milestone for the next release.

@xNaCly xNaCly added this to the Roadmap - v1.0.0 milestone Oct 13, 2022
xNaCly added a commit that referenced this issue Oct 18, 2022
# Migration to clap
fixes: #14 
fixes: #3
improves: #12
lays foundation for: #16 
## Changes:
- migrated to clap:
  ```text
  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`:
  ```text
  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
    ```bash
    # 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
    ```bash
    # 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:
    ```bash
    # 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:
    ```bash
    # 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:
    ```text
    [2]: 'update excel sheet' (2022-10-13) #work [,,,]
    ```
  - after:
    ```
    [2]: 'update excel sheet' (2022-10-13) #work .3 FINISHED
    ```
xNaCly added a commit that referenced this issue Oct 19, 2022
- added two flags to the opus list command:
  --sort_by=<id, due, finished, title, priority, tag>
  --sort_order=<asc, desc>
- renamed SortDirection to SortOrder
- updated tests to include new cli::cli_get_tasks parameters
- changed Database::get_tasks::sql_query to type String
@xNaCly xNaCly mentioned this issue Oct 19, 2022
@xNaCly xNaCly linked a pull request Oct 19, 2022 that will close this issue
xNaCly added a commit that referenced this issue Oct 19, 2022
* feat: add foundation for sorting
- add command flag --sort_by to clap parsing
- add SortMode and SortDirection enums
- add the above as params to cli::cli_get_tasks, db::Database::get_tasks

* test: add missing asserts to task.compare_content() calls (#18)

* test: add missing asserts to task.compare_content() calls

While refactoring the test task compare code into `Task::content_compare`
the asserts went missing (oh no). Adds them back so that if the
comparsion return false the tests will fail.

* test: fix finish_task test

* feat: implemented #16 (sorting for opus list)

- added two flags to the opus list command:
  --sort_by=<id, due, finished, title, priority, tag>
  --sort_order=<asc, desc>
- renamed SortDirection to SortOrder
- updated tests to include new cli::cli_get_tasks parameters
- changed Database::get_tasks::sql_query to type String

* fix: correct help message for --sort_order

* doc: added list sorting documentation

* refactor: changed '_' in opus list flags to '-'

* chore: update version to reflect experimental feat

$ opus -V
opus 0.2.0-alpha+experimental.ls-sorting

Co-authored-by: Daniel <[email protected]>
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 a pull request may close this issue.

2 participants