use clap::{App, Arg, SubCommand};

pub fn subcommand() -> App<'static, 'static> {
    SubCommand::with_name("list")
           .about("List the issues from JIRA.")
           .arg(Arg::with_name("project")
               .help("Project Code to filter with.")
               .short("p")
               .long("project")
               .value_name("PROJECT")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("assignee")
               .help("Assignee username or email to filter with.")
               .short("a")
               .long("assignee")
               .value_name("ASSIGNEE")
               .takes_value(true)
               .multiple(true)
               )
             .arg(Arg::with_name("me")
               .help("Issues assigned to you.")
               .short("M")
               .long("me")
               .value_name("ME")
               .takes_value(false)
               )
             .arg(Arg::with_name("json")
               .help("JSON response")
               .short("J")
               .long("json")
               .value_name("JSON")
               .takes_value(false)
               )
            .arg(Arg::with_name("component")
               .help("Component name or ID to filter with.")
               .short("c")
               .long("component")
               .value_name("COMPONENT")
               .takes_value(true)
               .multiple(true)
               )
             .arg(Arg::with_name("display")
               .short("d")
               .long("display")
               .long_help(" Comma separated list of fields to display.
Possible options for fields are:
key,resolution,priority,assignee,status,components,creator,reporter,issuetype,project,summary

You can pass alias as option for display. You can save alias using alias subcommand for the application.

 Default options are
 key,summary,status,assignee
                   ")
               .value_name("DISPLAY")
               .takes_value(true)
               )
            .arg(Arg::with_name("epic")
               .help("EPIC name or issue key of epic to filter with.")
               .short("e")
               .long("epic")
               .value_name("EPIC")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("filter")
               .help("Filter name or filter id that you saved in JIRA.")
               .short("f")
               .long("filter")
               .value_name("FILTER")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("jql")
               .help("JQL Query or alias to JQL query to filter with.")
               .short("j")
               .long("jql")
               .value_name("JQL")
               .takes_value(true)
               )
            .arg(Arg::with_name("labels")
               .help("Search for issues with a label or list of labels.")
               .short("l")
               .long("label")
               .value_name("LABEL")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("parent")
               .help("Search for subtask of a particular issue.")
               .short("m")
               .long("main")
               .value_name("PARENT")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("priority")
               .help("Search for issues with a particular priority.")
               .short("P")
               .long("priority")
               .value_name("PRIORITY")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("reporter")
               .help("Search for issues that were reported by a particular user.")
               .short("r")
               .long("reporter")
               .value_name("REPORTER")
               .takes_value(true)
               .multiple(true)
               )
           .arg(Arg::with_name("sprint")
               .help("Search for issues that are assigned to a particular sprint.")
               .short("s")
               .long("sprint")
               .value_name("SPRINT")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("status")
               .help("Search for issues that have a particular status.")
               .short("S")
               .long("status")
               .value_name("STATUS")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("type")
               .help("Search for issues that have a particular issue type. ")
               .short("t")
               .long("type")
               .value_name("TYPE")
               .takes_value(true)
               .multiple(true)
               )
            .arg(Arg::with_name("text")
               .help("This is a master-field that allows you to search all text fields for issues.")
               .short("T")
               .long("text")
               .value_name("TEXT")
               .takes_value(true)
               )
            .arg(Arg::with_name("count")
               .help("Total number of issues to show. (Default is 50)")
               .short("C")
               .long("count")
               .value_name("COUNT")
               .takes_value(true)
               )
            .arg(Arg::with_name("offset")
               .help("Offset to start the first item to return in a page of results. (Default is 0)")
               .short("o")
               .long("offset")
               .value_name("OFFSET")
               .takes_value(true)
               )
            .arg(Arg::with_name("alias")
               .help("Save the applied options as an alias. You can use it with jql option later.")
               .short("A")
               .long("alias")
               .value_name("ALIAS")
               .takes_value(true)
               )
            .after_help("You can specify the following fields multiple time to filter by multiple values.
assignee, component, epic, filter, label, main, priority, project, reporter, sprint, status, type.

For example to fetch list of tickets in Backlog and In progress, you can use
jira-terminal list -s Backlog -s 'In Progress'
            ")
}
