def get_params_from_doc(cmd, style=u'--', help_flag=None, trap_error=True):
 res = CommandLine((u'which %s' % cmd.split(u' ')[0]), terminal_output=u'allatonce').run()
 cmd_path = res.runtime.stdout.strip()
 if (cmd_path == u''):
  raise Exception((u'Command %s not found' % cmd.split(u' ')[0]))
 if help_flag:
  cmd = u' '.join((cmd, help_flag))
 doc = grab_doc(cmd, trap_error)
 return _parse_doc(doc, style)

def get_params_from_doc ( cmd , style = u'--' , help_flag = None , trap_error = True ) : res = CommandLine ( ( u'which %s' % cmd . split ( u' ' ) [ 0 ] ) , terminal_output = u'allatonce' ) . run ( ) cmd_path = res . runtime . stdout . strip ( ) if ( cmd_path == u'' ) : raise Exception ( ( u'Command %s not found' % cmd . split ( u' ' ) [ 0 ] ) ) if help_flag : cmd = u' ' . join ( ( cmd , help_flag ) ) doc = grab_doc ( cmd , trap_error ) return _parse_doc ( doc , style )
auto-generate option map from command line help parameters cmd : string the command whose documentation we are fetching style : string default [--] the help command style .