Welcome to mirror list, hosted at ThFree Co, Russian Federation.

argumentparser.py « common « nextcloud_news_updater - github.com/nextcloud/news-updater.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 72da9c207ab401fd8e14ffa7b5df3c46fbeff48e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import argparse
from typing import Any

from nextcloud_news_updater.version import get_version


class ArgumentParser:
    def __init__(self) -> None:
        self.parser = argparse.ArgumentParser()
        self.parser.add_argument('--threads', '-t',
                                 help='How many feeds should be fetched in '
                                      'parallel, defaults to 10',
                                 type=int)
        self.parser.add_argument('--timeout', '-s',
                                 help='Maximum number of seconds for updating '
                                      'a feed, defaults to 5 minutes',
                                 type=int)
        self.parser.add_argument('--interval', '-i',
                                 help='Update interval between fetching the '
                                      'next round of updates in seconds, '
                                      'defaults to 15 minutes. The update '
                                      'timespan will be subtracted from the '
                                      'interval.',
                                 type=int)
        self.parser.add_argument('--apilevel', '-a',
                                 help='API level. Use v15 for News 15 or later'
                                      ', or v1-2 for releases prior to that',
                                 choices=['v1-2', 'v2', 'v15'])
        self.parser.add_argument('--loglevel', '-l',
                                 help='Log granularity, info will log all '
                                      'urls and received data, error will '
                                      'only log errors',
                                 choices=['info', 'error'])
        self.parser.add_argument('--config', '-c',
                                 help='Path to config file where all '
                                      'parameters except can be defined as '
                                      'key values pair.  See the ' 
                                      'README.rst for more information')
        self.parser.add_argument('--phpini', '-P',
                                 help='Custom absolute path to the php.ini '
                                      'file to use for the command line '
                                      'updater. If omitted, the default one '
                                      'will be used')
        self.parser.add_argument('--user', '-u',
                                 help='Admin username to log into Nextcloud. '
                                      'Must be specified on the command line '
                                      'or in the config file if the updater '
                                      'should update over HTTP')
        self.parser.add_argument('--password', '-p',
                                 help='Admin password to log into Nextcloud '
                                      'if the updater should update over HTTP'
                                 )
        self.parser.add_argument('--version', '-v', action='version',
                                 version=get_version(),
                                 help='Prints the updater\'s version')
        self.parser.add_argument('--mode', '-m',
                                 help='Mode to run the updater in: endless '
                                      'runs the update again after the '
                                      'specified interval, singlerun only '
                                      'executes the update once',
                                 choices=['endless', 'singlerun'])
        self.parser.add_argument('--php',
                                 help='Path to the PHP binary, '
                                      'e.g. /usr/bin/php7.0, defaults to '
                                      'php')
        self.parser.add_argument('url',
                                 help='The URL or absolute path to the '
                                      'directory where Nextcloud is installed.'
                                      ' Must be specified on the command line '
                                      'or in the config file. If the URL '
                                      'starts with http:// or https://, a '
                                      'user and password are required. '
                                      'Otherwise the updater tries to use the '
                                      'console based API which was added in '
                                      '8.1.0',
                                 nargs='?')

    def parse(self) -> Any:
        return self.parser.parse_args()

    def print_help(self, file: Any) -> None:
        self.parser.print_help(file)