Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] all tools should have a uniform options list #15

Open
underwoo opened this issue Sep 12, 2022 · 0 comments
Open

[Suggestion] all tools should have a uniform options list #15

underwoo opened this issue Sep 12, 2022 · 0 comments

Comments

@underwoo
Copy link
Member

The field_table converter uses a different set of options (that is field_table has no options) from the diag and data table converter scripts. All should use a similar set of options.

Also, I feel a change in the options and default behavior will make the tools easier to use.

As currently written, all have a default file name to use. I feel the default should be removed and require the user to specify the table file to convert, and that file should be the first argument on the line. E.g.,

> table_to_yaml table_file

The diag_table_to_yaml and diag_table_to_yaml scripts require the file to convert be listed with the -f option. This change will make the -f option no longer needed.

I also feel by default the conversion should print the output to stdout. This can then be captured (or redirected to a file table_to_yaml table_file > output.yaml). An option -o should also be added to write converted file out (e.g., table_to_yaml -f output.yaml table_file). I feel these changes make the scripts more intuitive.

It will be useful both for users and when debugging to have a verbose option that prints additional information out to stderr. To help with this, the python [logging] (https://docs.python.org/3/library/logging.html#module-logging) can be useful to print warnings, errors, etc to either a log file (useful when run in FRE) or stderr/stdout.

As an example, the argparse code for the scripts would look similar to:

from pathlib import Path

parser = argparse.ArgumentParser(prog='table_to_yaml',
                                 description="Converts a legacy ascii table to a yaml table.")
parser.add_argument('-o', '--output',
                    help='Output file',
                    metaVar="outFile",
                    dest="outFile",
                    default=None,
                    type=Path)
parser.add_argument('-v', '--verbose',
                    help='Verbosity level',
                    metaVar="verbose",
                    dest="verbose",
                    default=0,
                    action=count)
parser.add_argument('table_file',
                    help="Table file to read",
                    metavar=table_file,
                    type=Path,
                    required=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant