@@ -2,8 +2,8 @@ use crate::bug_report;
2
2
use anyhow:: { anyhow, Result } ;
3
3
use asyncgit:: sync:: RepoPath ;
4
4
use clap:: {
5
- crate_authors, crate_description, crate_name, crate_version,
6
- App as ClapApp , Arg ,
5
+ crate_authors, crate_description, crate_name, crate_version, Arg ,
6
+ Command as ClapApp ,
7
7
} ;
8
8
use simplelog:: { Config , LevelFilter , WriteLogger } ;
9
9
use std:: {
@@ -21,17 +21,18 @@ pub fn process_cmdline() -> Result<CliArgs> {
21
21
let app = app ( ) ;
22
22
23
23
let arg_matches = app. get_matches ( ) ;
24
- if arg_matches. is_present ( "bugreport" ) {
24
+ if arg_matches. contains_id ( "bugreport" ) {
25
25
bug_report:: generate_bugreport ( ) ;
26
26
std:: process:: exit ( 0 ) ;
27
27
}
28
- if arg_matches. is_present ( "logging" ) {
28
+ if arg_matches. contains_id ( "logging" ) {
29
29
setup_logging ( ) ?;
30
30
}
31
31
32
- let workdir = arg_matches. value_of ( "workdir" ) . map ( PathBuf :: from) ;
32
+ let workdir =
33
+ arg_matches. get_one :: < String > ( "workdir" ) . map ( PathBuf :: from) ;
33
34
let gitdir = arg_matches
34
- . value_of ( "directory" )
35
+ . get_one :: < String > ( "directory" )
35
36
. map_or_else ( || PathBuf :: from ( "." ) , PathBuf :: from) ;
36
37
37
38
#[ allow( clippy:: option_if_let_else) ]
@@ -41,10 +42,11 @@ pub fn process_cmdline() -> Result<CliArgs> {
41
42
RepoPath :: Path ( gitdir)
42
43
} ;
43
44
44
- let arg_theme =
45
- arg_matches. value_of ( "theme" ) . unwrap_or ( "theme.ron" ) ;
45
+ let arg_theme = arg_matches
46
+ . get_one :: < String > ( "theme" )
47
+ . map_or_else ( || PathBuf :: from ( "theme.ron" ) , PathBuf :: from) ;
46
48
47
- if get_app_config_path ( ) ?. join ( arg_theme) . is_file ( ) {
49
+ if get_app_config_path ( ) ?. join ( & arg_theme) . is_file ( ) {
48
50
Ok ( CliArgs {
49
51
theme : get_app_config_path ( ) ?. join ( arg_theme) ,
50
52
repo_path,
@@ -57,47 +59,58 @@ pub fn process_cmdline() -> Result<CliArgs> {
57
59
}
58
60
}
59
61
60
- fn app ( ) -> ClapApp < ' static > {
61
- let app = ClapApp :: new ( crate_name ! ( ) )
62
+ fn app ( ) -> ClapApp {
63
+ ClapApp :: new ( crate_name ! ( ) )
62
64
. author ( crate_authors ! ( ) )
63
65
. version ( crate_version ! ( ) )
64
66
. about ( crate_description ! ( ) )
67
+ . help_template (
68
+ "\
69
+ {before-help}gitui {version}
70
+ {author}
71
+ {about}
72
+
73
+ {usage-heading} {usage}
74
+
75
+ {all-args}{after-help}
76
+ " ,
77
+ )
65
78
. arg (
66
- Arg :: with_name ( "theme" )
79
+ Arg :: new ( "theme" )
67
80
. help ( "Set the color theme (defaults to theme.ron)" )
68
81
. short ( 't' )
69
82
. long ( "theme" )
70
83
. value_name ( "THEME" )
71
- . takes_value ( true ) ,
84
+ . num_args ( 1 ) ,
72
85
)
73
86
. arg (
74
- Arg :: with_name ( "logging" )
87
+ Arg :: new ( "logging" )
75
88
. help ( "Stores logging output into a cache directory" )
76
89
. short ( 'l' )
77
- . long ( "logging" ) ,
90
+ . long ( "logging" )
91
+ . num_args ( 0 ) ,
78
92
)
79
93
. arg (
80
- Arg :: with_name ( "bugreport" )
94
+ Arg :: new ( "bugreport" )
81
95
. help ( "Generate a bug report" )
82
96
. long ( "bugreport" ) ,
83
97
)
84
98
. arg (
85
- Arg :: with_name ( "directory" )
99
+ Arg :: new ( "directory" )
86
100
. help ( "Set the git directory" )
87
101
. short ( 'd' )
88
102
. long ( "directory" )
89
103
. env ( "GIT_DIR" )
90
- . takes_value ( true ) ,
104
+ . num_args ( 1 ) ,
91
105
)
92
106
. arg (
93
- Arg :: with_name ( "workdir" )
107
+ Arg :: new ( "workdir" )
94
108
. help ( "Set the working directory" )
95
109
. short ( 'w' )
96
110
. long ( "workdir" )
97
111
. env ( "GIT_WORK_TREE" )
98
- . takes_value ( true ) ,
99
- ) ;
100
- app
112
+ . num_args ( 1 ) ,
113
+ )
101
114
}
102
115
103
116
fn setup_logging ( ) -> Result < ( ) > {
0 commit comments