diff --git a/stone/backends/swift_client.py b/stone/backends/swift_client.py index bef41519..85adebd2 100644 --- a/stone/backends/swift_client.py +++ b/stone/backends/swift_client.py @@ -97,6 +97,11 @@ action='store_true', help='Generate the Objective-C compatibile files.', ) +_cmdline_parser.add_argument( + '--objc-shim', + action='store_true', + help='Generate the Objective-C to Swift migration files.', +) class SwiftBackend(SwiftBaseBackend): @@ -172,6 +177,7 @@ def _generate_client(self, api): self._write_output_in_target_folder(template.render(), 'DBX{}.swift'.format(self.args.module_name)) + elif self.args.objc_shim: self._generate_sdk_migration_shim(api) else: template = self._jinja_template("SwiftClient.jinja") @@ -235,6 +241,8 @@ def _generate_routes(self, namespace): self._write_output_in_target_folder(output_from_parsed_template, 'DBX{}Routes.swift'.format(ns_class)) + elif self.args.objc_shim: + return else: template = self._jinja_template("SwiftRoutes.jinja") template.globals = template_globals @@ -273,6 +281,8 @@ def _generate_request_boxes(self, api): file_name = 'DBX{}RequestBox.swift'.format(self.args.class_name) self._write_output_in_target_folder(output, file_name) + elif self.args.objc_shim: + return else: template = self._jinja_template("SwiftRequestBox.jinja") template.globals = template_globals diff --git a/stone/backends/swift_types.py b/stone/backends/swift_types.py index b5479e56..130cc1c3 100644 --- a/stone/backends/swift_types.py +++ b/stone/backends/swift_types.py @@ -70,7 +70,7 @@ _cmdline_parser.add_argument( '--objc', action='store_true', - help='Generate the Objective-C compatibile files', + help='Generate the Objective-C compatibile files.', ) _cmdline_parser.add_argument( '-d', @@ -78,6 +78,11 @@ action='store_true', help=('Sets whether documentation is generated.'), ) +_cmdline_parser.add_argument( + '--objc-shim', + action='store_true', + help='Generate the Objective-C to Swift migration files.', +) class SwiftTypesBackend(SwiftBaseBackend): """ @@ -203,9 +208,7 @@ def generate(self, api): template_globals['swift_union_arg_to_objc'] = self._swift_union_arg_to_objc template_globals['union_swift_arg_guard'] = self._union_swift_arg_guard - shim_flag = self.args.objc - - if shim_flag: + if self.args.objc_shim: self._add_shim_template_globals(template_globals) swift_template_file = "SwiftTypes.jinja" @@ -232,12 +235,7 @@ def generate(self, api): route_schema=api.route_schema) self._write_output_in_target_folder(objc_output, 'DBX{}.swift'.format(ns_class)) - else: - swift_output = swift_template.render(namespace=namespace, - route_schema=api.route_schema) - self._write_output_in_target_folder(swift_output, - '{}.swift'.format(ns_class)) - if shim_flag: + elif self.args.objc_shim: shim_output = shim_template.render(namespace=namespace, route_schema=api.route_schema) self._write_output_in_target_folder(shim_output, @@ -246,7 +244,11 @@ def generate(self, api): route_schema=api.route_schema) self._write_output_in_target_folder(arg_shim_output, 'ShimArgTypeMappings{}.swift'.format(ns_class)) - + else: + swift_output = swift_template.render(namespace=namespace, + route_schema=api.route_schema) + self._write_output_in_target_folder(swift_output, + '{}.swift'.format(ns_class)) if self.args.documentation: self._generate_jazzy_docs(api)