From a6b2a46bbcd357d69f084dab8568711a5e20d038 Mon Sep 17 00:00:00 2001 From: "Mark A. Miller" Date: Wed, 29 Mar 2023 16:23:11 -0400 Subject: [PATCH] #99 --- schemasheets/schemamaker.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/schemasheets/schemamaker.py b/schemasheets/schemamaker.py index 13cbcdf..112d4f6 100644 --- a/schemasheets/schemamaker.py +++ b/schemasheets/schemamaker.py @@ -598,6 +598,9 @@ def ensure_csvreader(self, file_name: str, delimiter=None) -> str: type=click.File(mode="w"), default=sys.stdout, help="output file") +@click.option('-s', '--sort-keys', + default=False, + help="Sort keys in schema output? For example permissible values in an enumeration? Defaults to False.") @click.option("-n", "--name", help="name of the schema") @click.option("-C", "--table-config-path", @@ -619,7 +622,7 @@ def ensure_csvreader(self, file_name: str, delimiter=None) -> str: help="Google sheets ID. If this is specified then the arguments MUST be sheet names") @click.option("-v", "--verbose", count=True) @click.argument('tsv_files', nargs=-1) -def convert(tsv_files, gsheet_id, output: TextIO, name, repair, table_config_path: str, use_attributes: bool, unique_slots: bool, verbose: int): +def convert(tsv_files, gsheet_id, output: TextIO, name, repair, table_config_path: str, use_attributes: bool, unique_slots: bool, verbose: int, sort_keys: bool): """ Convert schemasheets to a LinkML schema @@ -649,7 +652,7 @@ def convert(tsv_files, gsheet_id, output: TextIO, name, repair, table_config_pat if repair: schema = sm.repair_schema(schema) schema_dict = schema_as_dict(schema) - output.write(yaml.dump(schema_dict)) + output.write(yaml.dump(schema_dict, sort_keys=sort_keys)) #output.write(yaml_dumper.dumps(schema))