@@ -58,21 +58,21 @@ impl fmt::Display for ConfigurationError {
5858}
5959
6060#[ derive( Debug ) ]
61- pub enum ArgumentError {
61+ pub enum CLIError {
6262 Configuration ( ConfigurationError ) ,
6363}
6464
65- impl fmt:: Display for ArgumentError {
65+ impl fmt:: Display for CLIError {
6666 fn fmt ( & self , f : & mut fmt:: Formatter ) -> Result < ( ) , fmt:: Error > {
6767 match * self {
68- ArgumentError :: Configuration ( ref err) => writeln ! ( f, "Configuration -> {}" , err)
68+ CLIError :: Configuration ( ref err) => writeln ! ( f, "Configuration -> {}" , err)
6969 }
7070 }
7171}
7272
7373#[ derive( Debug ) ]
7474pub struct InvalidOptionsError {
75- pub issues : Vec < ArgumentError > ,
75+ pub issues : Vec < CLIError > ,
7676 pub exit_code : i32 ,
7777}
7878
@@ -86,24 +86,24 @@ impl fmt::Display for InvalidOptionsError {
8686}
8787
8888impl InvalidOptionsError {
89- pub fn single ( err : ArgumentError , exit_code : i32 ) -> InvalidOptionsError {
89+ pub fn single ( err : CLIError , exit_code : i32 ) -> InvalidOptionsError {
9090 InvalidOptionsError {
9191 issues : vec ! [ err] ,
9292 exit_code : exit_code,
9393 }
9494 }
9595}
9696
97- pub fn assure_config_dir_exists ( dir : & str ) -> Result < String , ArgumentError > {
97+ pub fn assure_config_dir_exists ( dir : & str ) -> Result < String , CLIError > {
9898 let trdir = dir. trim ( ) ;
9999 if trdir. len ( ) == 0 {
100- return Err ( ArgumentError :: Configuration ( ConfigurationError :: DirectoryUnset ) )
100+ return Err ( CLIError :: Configuration ( ConfigurationError :: DirectoryUnset ) )
101101 }
102102
103103 let expanded_config_dir =
104104 if trdir. as_bytes ( ) [ 0 ] == b'~' {
105105 match env:: var ( "HOME" ) . ok ( ) . or ( env:: var ( "UserProfile" ) . ok ( ) ) {
106- None => return Err ( ArgumentError :: Configuration ( ConfigurationError :: HomeExpansionFailed ( trdir. to_string ( ) ) ) ) ,
106+ None => return Err ( CLIError :: Configuration ( ConfigurationError :: HomeExpansionFailed ( trdir. to_string ( ) ) ) ) ,
107107 Some ( mut user) => {
108108 user. push_str ( & trdir[ 1 ..] ) ;
109109 user
@@ -115,19 +115,19 @@ pub fn assure_config_dir_exists(dir: &str) -> Result<String, ArgumentError> {
115115
116116 if let Err ( err) = fs:: create_dir ( & expanded_config_dir) {
117117 if err. kind ( ) != io:: ErrorKind :: AlreadyExists {
118- return Err ( ArgumentError :: Configuration (
118+ return Err ( CLIError :: Configuration (
119119 ConfigurationError :: DirectoryCreationFailed ( ( expanded_config_dir, err) ) ) )
120120 }
121121 }
122122
123123 Ok ( expanded_config_dir)
124124}
125125
126- pub fn application_secret_from_directory ( dir : & str , secret_basename : & str ) -> Result < ApplicationSecret , ArgumentError > {
126+ pub fn application_secret_from_directory ( dir : & str , secret_basename : & str ) -> Result < ApplicationSecret , CLIError > {
127127 let secret_path = Path :: new ( dir) . join ( secret_basename) ;
128128 let secret_str = || secret_path. as_path ( ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
129129 let secret_io_error = |io_err : io:: Error | {
130- Err ( ArgumentError :: Configuration ( ConfigurationError :: IOError (
130+ Err ( CLIError :: Configuration ( ConfigurationError :: IOError (
131131 ( secret_str ( ) , io_err)
132132 ) ) )
133133 } ;
@@ -173,14 +173,14 @@ pub fn application_secret_from_directory(dir: &str, secret_basename: &str) -> Re
173173 return secret_io_error ( io_err)
174174 }
175175 match json:: decode :: < ConsoleApplicationSecret > ( & json_encoded_secret) {
176- Err ( json_decode_error) => return Err ( ArgumentError :: Configuration (
176+ Err ( json_decode_error) => return Err ( CLIError :: Configuration (
177177 ConfigurationError :: Secret ( ApplicationSecretError :: DecoderError (
178178 ( secret_str ( ) , json_decode_error)
179179 ) ) ) ) ,
180180 Ok ( console_secret) => match console_secret. installed {
181181 Some ( secret) => return Ok ( secret) ,
182182 None => return Err (
183- ArgumentError :: Configuration (
183+ CLIError :: Configuration (
184184 ConfigurationError :: Secret (
185185 ApplicationSecretError :: FormatError ( secret_str ( ) )
186186 ) ) )
0 commit comments