@@ -215,9 +215,9 @@ enum Commands {
215215 /// one JSON contract per request, mirroring the collection's folder nesting.
216216 /// Files are written under `--destination`, resolved within the configured
217217 /// working directory; when omitted, the working directory itself is used.
218- /// `..` escapes and absolute paths elsewhere are rejected, and existing
219- /// files are never overwritten. Requires an initialized apic project
220- /// (`apic init`).
218+ /// `..` escapes and absolute paths elsewhere are rejected. An existing
219+ /// contract is left untouched unless `--force` is passed. Requires an
220+ /// initialized apic project (`apic init`).
221221 Convert {
222222 /// Path to the Postman collection JSON file to import.
223223 #[ arg( long, value_name = "FILE" ) ]
@@ -228,6 +228,10 @@ enum Commands {
228228 /// directory from `.apic/config.toml`.
229229 #[ arg( long, value_name = "DIR" ) ]
230230 destination : Option < String > ,
231+
232+ /// Overwrite contracts that already exist instead of erroring.
233+ #[ arg( long) ]
234+ force : bool ,
231235 } ,
232236}
233237
@@ -260,7 +264,7 @@ fn init_cmd(working_dir: Option<&str>) -> Result<(), String> {
260264 println ! ( "Successfully initialized" ) ;
261265 }
262266 InitOutcome :: TemplateSeeded => {
263- println ! ( "Already initialized; created the missing template" )
267+ println ! ( "Already initialized, created the missing template" )
264268 }
265269 }
266270 Ok ( ( ) )
@@ -467,9 +471,9 @@ fn select_create_template(
467471fn no_template_error ( name : & str , templates : & [ PathBuf ] , root : & Path ) -> String {
468472 let mut msg = format ! ( "no template matching '{}'" , sanitize( name) ) ;
469473 if templates. is_empty ( ) {
470- msg. push_str ( "; no templates in .apic/template/" ) ;
474+ msg. push_str ( ", no templates in .apic/template/" ) ;
471475 } else {
472- msg. push_str ( "; available:\n " ) ;
476+ msg. push_str ( ", available:\n " ) ;
473477 for t in templates {
474478 msg. push_str ( & format ! ( " {}\n " , rel_display( t, root) ) ) ;
475479 }
@@ -772,7 +776,7 @@ fn validate_cmd(template: bool, find: Option<&str>) -> Result<(), String> {
772776 if issues. is_empty ( ) {
773777 Ok ( ( ) )
774778 } else {
775- Err ( issues. join ( "; " ) )
779+ Err ( issues. join ( ", " ) )
776780 }
777781 } ) ;
778782
@@ -804,13 +808,13 @@ fn validate_template_cmd() -> Result<(), String> {
804808 let apic_dir = match apic_core:: config:: find_apic_dir ( ) {
805809 Some ( dir) => dir,
806810 None => {
807- println ! ( "No project template found; create will use the built-in template" ) ;
811+ println ! ( "No project template found, create will use the built-in template" ) ;
808812 return Ok ( ( ) ) ;
809813 }
810814 } ;
811815 let templates = apic_core:: template:: list_templates ( & apic_dir) ;
812816 if templates. is_empty ( ) {
813- println ! ( "No project template found; create will use the built-in template" ) ;
817+ println ! ( "No project template found, create will use the built-in template" ) ;
814818 return Ok ( ( ) ) ;
815819 }
816820
@@ -1108,13 +1112,13 @@ fn remove_template_cmd(name: &str) -> Result<(), String> {
11081112
11091113/// Handles `apic convert`: resolve the destination under the working directory,
11101114/// then parse the Postman collection and write contracts.
1111- fn convert_cmd ( postman : & Path , destination : Option < & str > ) -> Result < ( ) , String > {
1115+ fn convert_cmd ( postman : & Path , destination : Option < & str > , force : bool ) -> Result < ( ) , String > {
11121116 let root = read_config_file ( ) . and_then ( |conf| conf. get_root_dir ( ) ) ?;
11131117 let dest_base = match destination {
11141118 Some ( dir) => confine_to_dir ( & root, Path :: new ( dir) ) ?,
11151119 None => root,
11161120 } ;
1117- let outcome = apic_core:: convert:: run ( postman, & dest_base) ?;
1121+ let outcome = apic_core:: convert:: run ( postman, & dest_base, force ) ?;
11181122 for warning in & outcome. warnings {
11191123 eprintln ! ( "warning: {warning}" ) ;
11201124 }
@@ -1294,7 +1298,8 @@ pub(crate) fn run() {
12941298 Commands :: Convert {
12951299 postman,
12961300 destination,
1297- } => convert_cmd ( & postman, destination. as_deref ( ) ) ,
1301+ force,
1302+ } => convert_cmd ( & postman, destination. as_deref ( ) , force) ,
12981303 } ;
12991304
13001305 if let Err ( err) = result {
0 commit comments