Example #1
0
 def usage(self):
     """
     Format this command's usage string
     """
     tpl = Template("Usage: ${cmd_name} ${options}${cmd_args}")
     return tpl.safe_substitute(cmd_name=self.name,
                                options=self.options and "[options] " or "",
                                cmd_args=self.format_cmd_args())
Example #2
0
 def info(self):
     from holland.core.util.template import Template
     from textwrap import dedent, wrap
     tmpl = Template("""
     backup-plugin   = ${plugin}
     backup-started  = ${start-time}
     backup-finished = ${stop-time}
     estimated size  = ${estimated-size}
     on-disk size    = ${on-disk-size}
     """)
     str = tmpl.safe_substitute(self._formatted_config())
     str = "\t" + dedent(str).lstrip()
     str = "\n\t\t".join(str.splitlines())
     return str
Example #3
0
    def help(self):
        """
        Format this command's help output

        Default is to use the class' docstring as a 
        template and interpolate the name, options and 
        arguments
        """
        usage_str = getdoc(self) or ''
        usage_str = self.reformat_paragraphs(usage_str)
        cmd_name = self.name
        cmd_opts = self.format_cmd_options()
        cmd_args = self.format_cmd_args()
        help_str = Template(usage_str).safe_substitute(
            cmd_name=cmd_name,
            cmd_option_list=cmd_opts,
            cmd_args=cmd_args,
            cmd_usage=self.usage()).rstrip()
        return re.sub(r'\n\n+', r'\n\n', help_str)