def testQuote(self):
     parser = YokadiOptionParser()
     parser.add_argument("cmd", nargs='*')
     src = "There's a quote here"
     args = parser.parse_args(src)
     # Recreate the line
     line = " ".join(args.cmd)
     self.assertEqual(line, src)
 def testDash(self):
     parser = YokadiOptionParser()
     parser.add_argument("cmd", nargs="*")
     srcs = ["foo-bar", "foo - bar"]
     for src in srcs:
         args = parser.parse_args(src)
         # Recreate the line
         line = " ".join(args.cmd)
         self.assertEqual(line, src)
 def testDash(self):
     parser = YokadiOptionParser()
     parser.add_argument("cmd", nargs="*")
     srcs = ["foo-bar", "foo - bar"]
     for src in srcs:
         args = parser.parse_args(src)
         # Recreate the line
         line = " ".join(args.cmd)
         self.assertEqual(line, src)
Exemple #4
0
 def parser_p_merge(self):
     parser = YokadiOptionParser()
     parser.usage = "p_remove <source_project> <destination_project>"
     parser.description = "Merge <source_project> into <destination_project>."
     parser.add_argument("source_project")
     parser.add_argument("destination_project")
     parser.add_argument("-f",
                         dest="force",
                         default=False,
                         action="store_true",
                         help="Skip confirmation prompt")
     return parser
Exemple #5
0
 def parser_p_merge(self):
     parser = YokadiOptionParser()
     parser.usage = "p_remove <source_project> <destination_project>"
     parser.description = "Merge <source_project> into <destination_project>."
     parser.add_argument("source_project")
     parser.add_argument("destination_project")
     parser.add_argument("-f", dest="force", default=False, action="store_true",
                         help="Skip confirmation prompt")
     return parser
Exemple #6
0
 def _parser_t_add(self, cmd):
     """Code shared by t_add, bug_add and n_add parsers."""
     parser = YokadiOptionParser()
     parser.usage = "%s [options] <projectName> [@<keyword1>] [@<keyword2>] <title>" % cmd
     parser.description = "Add new %s. Will prompt to create keywords if they do not exist." % cmd
     parser.add_argument("-c", dest="crypt", default=False, action="store_true",
                       help="Encrypt title")
     parser.add_argument("-d", "--describe", dest="describe", default=False, action="store_true",
                       help="Directly open editor to describe task")
     parser.add_argument('cmd', nargs='*')
     return parser
Exemple #7
0
 def parser_p_remove(self):
     parser = YokadiOptionParser()
     parser.usage = "p_remove [options] <project_name>"
     parser.description = "Remove a project and all its associated tasks."
     parser.add_argument("-f", dest="force", default=False, action="store_true",
                       help="Skip confirmation prompt")
     parser.add_argument("project")
     return parser
Exemple #8
0
 def parser_t_show(self):
     parser = YokadiOptionParser()
     parser.usage = "t_show [options] <id>"
     parser.description = "Display details of a task."
     choices = ["all", "summary", "description"]
     parser.add_argument("--output", dest="output",
                       choices=choices,
                       default="all",
                       help="<output> can be one of %s. If not set, it defaults to all." % ", ".join(choices),
                       metavar="<output>")
     parser.add_argument("--decrypt", dest="decrypt", default=False, action="store_true",
                       help="Decrypt task title and description")
     parser.add_argument("id")
     return parser
Exemple #9
0
 def parser_p_remove(self):
     parser = YokadiOptionParser()
     parser.usage = "p_remove [options] <project_name>"
     parser.description = "Remove a project and all its associated tasks."
     parser.add_argument("-f", dest="force", default=False, action="store_true", help="Skip confirmation prompt")
     parser.add_argument("project")
     return parser
Exemple #10
0
 def parser_c_get(self):
     parser = YokadiOptionParser(prog="c_get")
     parser.description = "Display the value of a configuration key. If no key is given, all keys are shown."
     parser.add_argument("-s", dest="system", default=False, action="store_true",
                         help="Display value of system keys instead of user ones")
     parser.add_argument("key", nargs='?')
     return parser
Exemple #11
0
 def _parser_t_add(self, cmd):
     """Code shared by t_add, bug_add and n_add parsers."""
     parser = YokadiOptionParser()
     parser.usage = "%s [options] <projectName> [@<keyword1>] [@<keyword2>] <title>" % cmd
     parser.description = "Add new %s. Will prompt to create keywords if they do not exist." % cmd
     parser.add_argument("-c",
                         dest="crypt",
                         default=False,
                         action="store_true",
                         help="Encrypt title")
     parser.add_argument("-d",
                         "--describe",
                         dest="describe",
                         default=False,
                         action="store_true",
                         help="Directly open editor to describe task")
     parser.add_argument('cmd', nargs='*')
     return parser
Exemple #12
0
 def parser_t_remove(self):
     parser = YokadiOptionParser()
     parser.usage = "t_remove [options] <id>"
     parser.description = "Delete a task."
     parser.add_argument("-f",
                         dest="force",
                         default=False,
                         action="store_true",
                         help="Skip confirmation prompt")
     parser.add_argument("id")
     return parser
Exemple #13
0
 def parser_t_remove(self):
     parser = YokadiOptionParser()
     parser.usage = "t_remove [options] <id>"
     parser.description = "Delete a task."
     parser.add_argument("-f", dest="force", default=False, action="store_true",
                       help="Skip confirmation prompt")
     parser.add_argument("id")
     return parser
Exemple #14
0
 def parser_t_show(self):
     parser = YokadiOptionParser()
     parser.usage = "t_show [options] <id>"
     parser.description = "Display details of a task."
     choices = ["all", "summary", "description"]
     parser.add_argument(
         "--output",
         dest="output",
         choices=choices,
         default="all",
         help="<output> can be one of %s. If not set, it defaults to all." %
         ", ".join(choices),
         metavar="<output>")
     parser.add_argument("--decrypt",
                         dest="decrypt",
                         default=False,
                         action="store_true",
                         help="Decrypt task title and description")
     parser.add_argument("id")
     return parser
Exemple #15
0
 def parser_t_purge(self):
     parser = YokadiOptionParser()
     parser.usage = "t_purge [options]"
     parser.description = "Remove old done tasks from all projects."
     parser.add_argument("-f", "--force", dest="force", default=False, action="store_true",
                       help="Skip confirmation prompt")
     delay = int(db.getConfigKey("PURGE_DELAY", environ=False))
     parser.add_argument("-d", "--delay", dest="delay", default=delay,
                       type=int, help="Delay (in days) after which done tasks are destroyed. Default is %d." % delay)
     return parser
Exemple #16
0
 def parser_c_get(self):
     parser = YokadiOptionParser(prog="c_get")
     parser.description = "Display the value of a configuration key. If no key is given, all keys are shown."
     parser.add_argument("-s", dest="system", default=False, action="store_true",
                       help="Display value of system keys instead of user ones")
     parser.add_argument("key", nargs='?')
     return parser
Exemple #17
0
    def parser_n_list(self):
        parser = YokadiOptionParser()
        parser.usage = "n_list [options] <project_or_keyword_filter>"
        parser.description = "List notes filtered by project and/or keywords. " \
            "'%' can be used as a wildcard in the project name: " \
            "to list projects starting with 'foo', use 'foo%'. " \
            "Keyword filtering is achieved with '@'. Ex.: " \
            "n_list @home, n_list @_bug=2394"

        parser.add_argument("-s", "--search", dest="search",
                            action="append",
                            help="only list notes whose title or description match <value>."
                                 " You can repeat this option to search on multiple words.",
                            metavar="<value>")

        parser.add_argument("-k", "--keyword", dest="keyword",
                            help="Group tasks by given keyword instead of project. The '%%' wildcard can be used.",
                            metavar="<keyword>")
        parser.add_argument("filter", nargs="*", metavar="<project_or_keyword_filter>")

        return parser
Exemple #18
0
 def parser_t_purge(self):
     parser = YokadiOptionParser()
     parser.usage = "t_purge [options]"
     parser.description = "Remove old done tasks from all projects."
     parser.add_argument("-f",
                         "--force",
                         dest="force",
                         default=False,
                         action="store_true",
                         help="Skip confirmation prompt")
     delay = int(Config.byName("PURGE_DELAY").value)
     parser.add_argument(
         "-d",
         "--delay",
         dest="delay",
         default=delay,
         type=int,
         help=
         "Delay (in days) after which done tasks are destroyed. Default is %d."
         % delay)
     return parser
Exemple #19
0
    def parser_t_list(self):
        parser = YokadiOptionParser()
        parser.usage = "t_list [options] <project_or_keyword_filter>"
        parser.description = "List tasks filtered by project and/or keywords. " \
                             "'%' can be used as a wildcard in the project name: " \
                             "to list projects starting with 'foo', use 'foo%'. " \
                             "Keyword filtering is achieved with '@'. Ex.: " \
                             "t_list @home, t_list @_bug=2394"

        parser.add_argument("-a", "--all", dest="status",
                          action="store_const", const="all",
                          help="all tasks (done and to be done)")

        parser.add_argument("--started", dest="status",
                          action="store_const", const="started",
                          help="only started tasks")

        rangeList = ["today", "thisweek", "thismonth", "all"]
        parser.add_argument("-d", "--done", dest="done",
                          help="only done tasks. <range> must be either one of %s or a date using the same format as t_due" % ", ".join(rangeList),
                          metavar="<range>")

        parser.add_argument("-u", "--urgency", dest="urgency",
                          type=int,
                          help="tasks with urgency greater or equal than <urgency>",
                          metavar="<urgency>")

        parser.add_argument("-t", "--top-due", dest="topDue",
                          default=False, action="store_true",
                          help="top 5 urgent tasks of each project based on due date")

        parser.add_argument("--overdue", dest="due",
                          action="append_const", const="now",
                          help="all overdue tasks")

        parser.add_argument("--due", dest="due",
                          action="append",
                          help="""only list tasks due before/after <limit>. <limit> is a
                          date optionaly prefixed with a comparison operator.
                          Valid operators are: <, <=, >=, and >.
                          Example of valid limits:

                          - tomorrow: due date <= tomorrow, 23:59:59
                          - today: due date <= today, 23:59:59
                          - >today: due date > today: 23:59:59
                          """,
                          metavar="<limit>")

        parser.add_argument("-k", "--keyword", dest="keyword",
                          help="Group tasks by given keyword instead of project. The %% wildcard can be used.",
                          metavar="<keyword>")

        parser.add_argument("-s", "--search", dest="search",
                          action="append",
                          help="only list tasks whose title or description match <value>. You can repeat this option to search on multiple words.",
                          metavar="<value>")

        formatList = ["auto"] + list(gRendererClassDict.keys())
        parser.add_argument("-f", "--format", dest="format",
                          default="auto", choices=formatList,
                          help="how should the task list be formated. <format> can be %s" % ", ".join(formatList),
                          metavar="<format>")
        parser.add_argument("-o", "--output", dest="output",
                          help="Output task list to <file>",
                          metavar="<file>")
        parser.add_argument("--decrypt", dest="decrypt", default=False, action="store_true",
                          help="Decrypt task title and description")

        parser.add_argument("filter", nargs="*", metavar="<project_or_keyword_filter>")

        return parser
Exemple #20
0
    def parser_n_list(self):
        parser = YokadiOptionParser()
        parser.usage = "n_list [options] <project_or_keyword_filter>"
        parser.description = "List notes filtered by project and/or keywords. " \
                                 "'%' can be used as a wildcard in the project name: " \
                                 "to list projects starting with 'foo', use 'foo%'. " \
                                 "Keyword filtering is achieved with '@'. Ex.: " \
                                 "n_list @home, n_list @_bug=2394"

        parser.add_argument(
            "-s",
            "--search",
            dest="search",
            action="append",
            help=
            "only list notes whose title or description match <value>. You can repeat this option to search on multiple words.",
            metavar="<value>")

        parser.add_argument(
            "-k",
            "--keyword",
            dest="keyword",
            help=
            "Group tasks by given keyword instead of project. The % wildcard can be used.",
            metavar="<keyword>")
        parser.add_argument("--decrypt",
                            dest="decrypt",
                            default=False,
                            action="store_true",
                            help="Decrypt note title and description")
        parser.add_argument("filter",
                            nargs="*",
                            metavar="<project_or_keyword_filter>")

        return parser
Exemple #21
0
    def parser_t_list(self):
        parser = YokadiOptionParser()
        parser.usage = "t_list [options] <project_or_keyword_filter>"
        parser.description = "List tasks filtered by project and/or keywords. " \
                             "'%' can be used as a wildcard in the project name: " \
                             "to list projects starting with 'foo', use 'foo%'. " \
                             "Keyword filtering is achieved with '@'. Ex.: " \
                             "t_list @home, t_list @_bug=2394"

        parser.add_argument("-a",
                            "--all",
                            dest="status",
                            action="store_const",
                            const="all",
                            help="all tasks (done and to be done)")

        parser.add_argument("--started",
                            dest="status",
                            action="store_const",
                            const="started",
                            help="only started tasks")

        rangeList = ["today", "thisweek", "thismonth", "all"]
        parser.add_argument(
            "-d",
            "--done",
            dest="done",
            help=
            "only done tasks. <range> must be either one of %s or a date using the same format as t_due"
            % ", ".join(rangeList),
            metavar="<range>")

        parser.add_argument(
            "-u",
            "--urgency",
            dest="urgency",
            type=int,
            help="tasks with urgency greater or equal than <urgency>",
            metavar="<urgency>")

        parser.add_argument(
            "-t",
            "--top-due",
            dest="topDue",
            default=False,
            action="store_true",
            help="top 5 urgent tasks of each project based on due date")

        parser.add_argument("--overdue",
                            dest="due",
                            action="append_const",
                            const="now",
                            help="all overdue tasks")

        parser.add_argument(
            "--due",
            dest="due",
            action="append",
            help="""only list tasks due before/after <limit>. <limit> is a
                          date optionaly prefixed with a comparison operator.
                          Valid operators are: <, <=, >=, and >.
                          Example of valid limits:

                          - tomorrow: due date <= tomorrow, 23:59:59
                          - today: due date <= today, 23:59:59
                          - >today: due date > today: 23:59:59
                          """,
            metavar="<limit>")

        parser.add_argument(
            "-k",
            "--keyword",
            dest="keyword",
            help=
            "Group tasks by given keyword instead of project. The %% wildcard can be used.",
            metavar="<keyword>")

        parser.add_argument(
            "-s",
            "--search",
            dest="search",
            action="append",
            help=
            "only list tasks whose title or description match <value>. You can repeat this option to search on multiple words.",
            metavar="<value>")

        formatList = ["auto"] + gRendererClassDict.keys()
        parser.add_argument(
            "-f",
            "--format",
            dest="format",
            default="auto",
            choices=formatList,
            help="how should the task list be formated. <format> can be %s" %
            ", ".join(formatList),
            metavar="<format>")
        parser.add_argument("-o",
                            "--output",
                            dest="output",
                            help="Output task list to <file>",
                            metavar="<file>")
        parser.add_argument("--decrypt",
                            dest="decrypt",
                            default=False,
                            action="store_true",
                            help="Decrypt task title and description")

        parser.add_argument("filter",
                            nargs="*",
                            metavar="<project_or_keyword_filter>")

        return parser
    def testUknownOption(self):
        def parseUnknownOption():
            parser.parse_args("blabla -b")

        parser = YokadiOptionParser()
        self.assertRaises(YokadiException, parseUnknownOption)