Skip to content

create/update from file instead of command line #318

@Hefeweizen

Description

@Hefeweizen

Monitor creation/updating has to be done entirely from the command line. I believe there should be an option to specify a file to read from. This functionality means I can dog monitor show [id] > [id.json] and later dog monitor post/update [id.json].

I intend to implement this, but I'd like some feedback on the intended design.

Codewise, the easiest thing to do is to add argparse argument groups. This would give two versions of the command, one which has everything set on the command line, or one that would have everything defined in a file.

While the above is straight-forward, it would not allow dog monitor update --file [id.json] --name [override_name_in_file]. Implementing the override feature is doable, but there's a lot of custom logic to implement. The only way I see to do it is to set nargs='?' on all the existing arguments, set a default of 'EMPTY', and then write checks to see that either the file has it or that it's been specified on the command line. And that seems like a lot of work that argparse itself should be doing.

My inclination is to implement the command grouping for the base functionality and not worry about the override capability. Am I missing something? Any better ideas?

Thanks,
-- Hefeweizen

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions