Handler override options #229

Closed
derks opened this Issue Jan 23, 2014 · 1 comment

Comments

Projects
None yet
1 participant
@derks
Member

derks commented Jan 23, 2014

Adding a handler override option came up in issue #225 in that we want a combined 'output_handler' option, for example:

$ myapp -o json

Rather that passing --json, or --yaml, etc. This should be a built in feature that could be used for other cases (not yet known, maybe?):

class MyApp(CementApp):
    class Meta:
        extensions = ['json', 'yaml', 'mustache']
        output_handler = 'mustache'
        output_handler_override_option = ['-o', '--output']
        output_handler_override_help = "Override the output handler"

If you don't like the above, you might want to call it 'format'

class MyApp(CementApp):
    class Meta:
        extensions = ['json', 'yaml', 'mustache']
        output_handler = 'mustache'
        output_handler_override_option = ['-f', '--format']
        output_handler_override_help = "formatter to use to render output"

The help text displayed with --help could also include the available 'output_handler' options:

-o, --output         output handler override [json, yaml]

The default of 'mustache' doesn't have to be included... but also, might add a allow_output_handler_override = False option on OutputHandler so that only handlers that allow to use for override are included:

class JsonOutputHandler(CementOutputHandler):
    class Meta:
        label = 'json'
        overridable = True

class MustacheOutputHandler(CementOutputHandler):
     class Meta:
         label = 'mustache'
         overridable = False

It isn't likely that we will want to pass -o mustache because that is probably the default... though we do want -o json or -o yaml. Of course the developer could set overridable = True on mustache or other template output handlers if they want.

@ghost ghost assigned derks Jan 23, 2014

@derks

This comment has been minimized.

Show comment
Hide comment
@derks

derks Jan 23, 2014

Member

Note that the output_handler_override_option would only be added if there are any output handlers with overridable = True ... otherwise the option would not be visible/added to the CLI. Should also have a enable_handler_override_options to CementApp so that options are not added to apps annoyingly.

Member

derks commented Jan 23, 2014

Note that the output_handler_override_option would only be added if there are any output handlers with overridable = True ... otherwise the option would not be visible/added to the CLI. Should also have a enable_handler_override_options to CementApp so that options are not added to apps annoyingly.

@derks derks assigned derks and unassigned derks Aug 21, 2014

derks added a commit that referenced this issue Aug 29, 2014

derks added a commit that referenced this issue Aug 29, 2014

@derks derks closed this Aug 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment