Skip to content

Commit 0529f7d

Browse files
committed
Add pagination feature with list
Now count and offset can be used to manage pagination for list feature. Fixes #24
1 parent 2f2b35d commit 0529f7d

File tree

5 files changed

+41
-7
lines changed

5 files changed

+41
-7
lines changed

Cargo.lock

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "jira-terminal"
3-
version = "1.4.0"
3+
version = "1.5.0"
44
authors = ["Amrit Ghimire <[email protected]>"]
55
edition = "2018"
66
description = "This is a command line application that can be used as a personal productivity tool for interacting with JIRA"

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ jira-terminal help autocompletion
5959
```
6060

6161
```
62-
JIRA Terminal 1.2.0
62+
JIRA Terminal 1.5.0
6363
Amrit Ghimire <[email protected]>
6464
This is a command line application that can be used as a personal productivity tool for interacting with JIRA
6565
@@ -86,6 +86,7 @@ SUBCOMMANDS:
8686

8787
### List of Tickets
8888
```
89+
8990
jira-terminal-list
9091
List the issues from JIRA.
9192
@@ -101,8 +102,9 @@ OPTIONS:
101102
-A, --alias <ALIAS> Save the applied options as an alias. You can use it with jql option later.
102103
-a, --assignee <ASIGNEE>... Assignee username or email to filter with.
103104
-c, --component <COMPONENT>... Component name or ID to filter with.
105+
-C, --count <COUNT> Total number of issues to show. (Default is 50)
104106
-d, --display <DISPLAY> Comma separated list of fields to display.
105-
Possible options for fields are:
107+
Possible options for fields are:
106108
key,resolution,priority,assignee,status,components,creator,reporter,issuetype,project,summary
107109
108110
You can pass alias as option for display. You can save alias using alias
@@ -115,6 +117,7 @@ OPTIONS:
115117
-f, --filter <FILTER>... Filter name or filter id that you saved in JIRA.
116118
-j, --jql <JQL> JQL Query or alias to JQL query to filter with.
117119
-l, --label <LABEL>... Search for issues with a label or list of labels.
120+
-o, --offset <OFFSET> Offset to start the first item to return in a page of results. (Default is 0)
118121
-m, --main <PARENT>... Search for subtask of a particular issue.
119122
-P, --priority <PRIORITY>... Search for issues with a particular priority.
120123
-p, --project <PROJECT>... Project Code to filter with.

src/jira/lists.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,22 @@ fn form_jql(matches: &ArgMatches) -> String {
8484

8585
pub fn list_issues(matches: &ArgMatches) {
8686
let jql = form_jql(matches);
87-
let search_response = api::get_call_v3(format!("search?jql={}", jql));
87+
let offset_result = matches.value_of("offset").unwrap_or("0").parse::<u32>();
88+
if offset_result.is_err() {
89+
eprintln!("Invalid option passed to offset. ");
90+
std::process::exit(1);
91+
}
92+
let offset = offset_result.unwrap();
93+
let count_result = matches.value_of("count").unwrap_or("50").parse::<u32>();
94+
if count_result.is_err() {
95+
eprintln!("Invalid option passed to count. ");
96+
std::process::exit(1);
97+
}
98+
let count = count_result.unwrap();
99+
let search_response = api::get_call_v3(format!(
100+
"search?maxResults={}&startAt={}&jql={}",
101+
count, offset, jql
102+
));
88103
if search_response.is_err() {
89104
eprintln!("Error occured when searching tickets. ");
90105
std::process::exit(1);

src/subcommands/list.rs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub fn subcommand() -> App<'static, 'static> {
3838
.short("d")
3939
.long("display")
4040
.long_help(" Comma separated list of fields to display.
41-
Possible options for fields are:
41+
Possible options for fields are:
4242
key,resolution,priority,assignee,status,components,creator,reporter,issuetype,project,summary
4343
4444
You can pass alias as option for display. You can save alias using alias subcommand for the application.
@@ -135,6 +135,20 @@ You can pass alias as option for display. You can save alias using alias subcomm
135135
.value_name("TEXT")
136136
.takes_value(true)
137137
)
138+
.arg(Arg::with_name("count")
139+
.help("Total number of issues to show. (Default is 50)")
140+
.short("C")
141+
.long("count")
142+
.value_name("COUNT")
143+
.takes_value(true)
144+
)
145+
.arg(Arg::with_name("offset")
146+
.help("Offset to start the first item to return in a page of results. (Default is 0)")
147+
.short("o")
148+
.long("offset")
149+
.value_name("OFFSET")
150+
.takes_value(true)
151+
)
138152
.arg(Arg::with_name("alias")
139153
.help("Save the applied options as an alias. You can use it with jql option later.")
140154
.short("A")
@@ -146,6 +160,6 @@ You can pass alias as option for display. You can save alias using alias subcomm
146160
assignee, component, epic, filter, label, main, priority, project, reporter, sprint, status, type.
147161
148162
For example to fetch list of tickets in Backlog and In progress, you can use
149-
jira-terminal list -s Backlog -s 'In Progress'
163+
jira-terminal list -s Backlog -s 'In Progress'
150164
")
151165
}

0 commit comments

Comments
 (0)