@@ -93,39 +93,12 @@ impl FromStr for IncludedDependencies {
9393 }
9494}
9595
96- #[ derive( Debug , Clone , PartialEq , Eq ) ]
96+ #[ derive( Debug , Default , Clone , PartialEq , Eq ) ]
9797pub struct OutputOptions {
98- pub cdx_extension : CdxExtension ,
99- pub prefix : Prefix ,
98+ pub filename : FilenamePattern ,
10099 pub platform_suffix : PlatformSuffix ,
101100}
102101
103- impl Default for OutputOptions {
104- fn default ( ) -> Self {
105- Self {
106- cdx_extension : CdxExtension :: default ( ) ,
107- prefix : Prefix :: Pattern ( Pattern :: Bom ) ,
108- platform_suffix : PlatformSuffix :: default ( ) ,
109- }
110- }
111- }
112-
113- #[ derive( Debug , Default , Clone , PartialEq , Eq ) ]
114- pub enum CdxExtension {
115- Included ,
116- #[ default]
117- NotIncluded ,
118- }
119-
120- impl CdxExtension {
121- pub fn extension ( & self ) -> String {
122- match & self {
123- CdxExtension :: Included => ".cdx" . to_string ( ) ,
124- CdxExtension :: NotIncluded => "" . to_string ( ) ,
125- }
126- }
127- }
128-
129102#[ derive( Debug , Default , Clone , PartialEq , Eq ) ]
130103pub struct Features {
131104 pub all_features : bool ,
@@ -150,14 +123,14 @@ impl Target {
150123}
151124
152125#[ derive( Debug , Clone , PartialEq , Eq ) ]
153- pub enum Prefix {
154- Pattern ( Pattern ) ,
155- Custom ( CustomPrefix ) ,
126+ pub enum FilenamePattern {
127+ CrateName ,
128+ Custom ( FilenameOverride ) ,
156129}
157130
158- impl Default for Prefix {
131+ impl Default for FilenamePattern {
159132 fn default ( ) -> Self {
160- Self :: Pattern ( Pattern :: default ( ) )
133+ Self :: CrateName
161134 }
162135}
163136
@@ -187,14 +160,14 @@ impl FromStr for Pattern {
187160}
188161
189162#[ derive( Debug , Clone , PartialEq , Eq ) ]
190- pub struct CustomPrefix ( String ) ;
163+ pub struct FilenameOverride ( String ) ;
191164
192- impl CustomPrefix {
193- pub fn new ( custom_prefix : impl Into < String > ) -> Result < Self , PrefixError > {
165+ impl FilenameOverride {
166+ pub fn new ( custom_prefix : impl Into < String > ) -> Result < Self , FilenameOverrideError > {
194167 let prefix = custom_prefix. into ( ) ;
195168
196169 if prefix. contains ( std:: path:: MAIN_SEPARATOR ) {
197- Err ( PrefixError :: CustomPrefixError (
170+ Err ( FilenameOverrideError :: TheOne (
198171 std:: path:: MAIN_SEPARATOR . to_string ( ) ,
199172 ) )
200173 } else {
@@ -203,16 +176,16 @@ impl CustomPrefix {
203176 }
204177}
205178
206- impl ToString for CustomPrefix {
179+ impl ToString for FilenameOverride {
207180 fn to_string ( & self ) -> String {
208181 self . 0 . clone ( )
209182 }
210183}
211184
212185#[ derive( Error , Debug , PartialEq , Eq ) ]
213- pub enum PrefixError {
186+ pub enum FilenameOverrideError {
214187 #[ error( "Illegal characters in custom prefix string: {0}" ) ]
215- CustomPrefixError ( String ) ,
188+ TheOne ( String ) ,
216189}
217190
218191#[ derive( Debug , Default , Clone , PartialEq , Eq ) ]
@@ -285,25 +258,25 @@ mod test {
285258 use super :: * ;
286259
287260 #[ test]
288- fn it_should_error_for_a_prefix_with_a_path_separator ( ) {
289- let prefix = format ! ( "directory{}prefix " , std:: path:: MAIN_SEPARATOR ) ;
261+ fn it_should_error_for_a_filename_with_a_path_separator ( ) {
262+ let filename = format ! ( "directory{}filename " , std:: path:: MAIN_SEPARATOR ) ;
290263
291- let actual = CustomPrefix :: new ( prefix )
292- . expect_err ( "Should not have been able to create CustomPrefix with path separator" ) ;
264+ let actual = FilenameOverride :: new ( filename )
265+ . expect_err ( "Should not have been able to create Customfilename with path separator" ) ;
293266
294- let expected = PrefixError :: CustomPrefixError ( std:: path:: MAIN_SEPARATOR . to_string ( ) ) ;
267+ let expected = FilenameOverrideError :: TheOne ( std:: path:: MAIN_SEPARATOR . to_string ( ) ) ;
295268
296269 assert_eq ! ( actual, expected) ;
297270 }
298271
299272 #[ test]
300- fn it_should_create_a_custom_prefix_from_a_valid_string ( ) {
301- let prefix = "customprefix " . to_string ( ) ;
273+ fn it_should_create_a_custom_filename_from_a_valid_string ( ) {
274+ let filename = "customfilename " . to_string ( ) ;
302275
303- let actual = CustomPrefix :: new ( prefix . clone ( ) )
304- . expect ( "Should have been able to create CustomPrefix " ) ;
276+ let actual = FilenameOverride :: new ( filename . clone ( ) )
277+ . expect ( "Should have been able to create Customfilename " ) ;
305278
306- let expected = CustomPrefix ( prefix ) ;
279+ let expected = FilenameOverride ( filename ) ;
307280
308281 assert_eq ! ( actual, expected) ;
309282 }
0 commit comments