Browse Source

move cli setup into each command file

Change-Id: Iae9d39c7fc55649a64a76a8351a3a349cbe5c028
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
Doug Hellmann 2 years ago
parent
commit
6281ec4617
3 changed files with 38 additions and 25 deletions
  1. 2
    25
      downpour/app.py
  2. 18
    0
      downpour/export.py
  3. 18
    0
      downpour/query.py

+ 2
- 25
downpour/app.py View File

@@ -59,31 +59,8 @@ def main():
59 59
     config.register_argparse_arguments(parser, sys.argv, None)
60 60
     subparsers = parser.add_subparsers(title='commands')
61 61
 
62
-    do_export = subparsers.add_parser(
63
-        'export',
64
-        help='export data',
65
-    )
66
-    do_export.add_argument(
67
-        'resource_file',
68
-        help='the name of the file listing resources to be exported',
69
-    )
70
-    do_export.add_argument(
71
-        'output_path',
72
-        default='.',
73
-        nargs='?',
74
-        help='the name of a directory to use for output file(s)',
75
-    )
76
-    do_export.set_defaults(func=export.export_data)
77
-
78
-    do_query = subparsers.add_parser(
79
-        'query',
80
-        help='query to build an export list',
81
-    )
82
-    do_query.add_argument(
83
-        'resource_file',
84
-        help='the name of the file listing resources to be updated',
85
-    )
86
-    do_query.set_defaults(func=query.query_data)
62
+    export.register_command(subparsers)
63
+    query.register_command(subparsers)
87 64
 
88 65
     args = parser.parse_args(sys.argv[1:])
89 66
 

+ 18
- 0
downpour/export.py View File

@@ -24,6 +24,24 @@ from downpour import resources
24 24
 LOG = logging.getLogger(__name__)
25 25
 
26 26
 
27
+def register_command(subparsers):
28
+    do_export = subparsers.add_parser(
29
+        'export',
30
+        help='export data',
31
+    )
32
+    do_export.add_argument(
33
+        'resource_file',
34
+        help='the name of the file listing resources to be exported',
35
+    )
36
+    do_export.add_argument(
37
+        'output_path',
38
+        default='.',
39
+        nargs='?',
40
+        help='the name of a directory to use for output file(s)',
41
+    )
42
+    do_export.set_defaults(func=export_data)
43
+
44
+
27 45
 def export_data(cloud, config, args):
28 46
     output_path = args.output_path
29 47
 

+ 18
- 0
downpour/query.py View File

@@ -12,6 +12,24 @@
12 12
 # License for the specific language governing permissions and limitations
13 13
 # under the License.
14 14
 
15
+import logging
16
+
17
+import yaml
18
+
19
+LOG = logging.getLogger(__name__)
20
+
21
+
22
+def register_command(subparsers):
23
+    do_query = subparsers.add_parser(
24
+        'query',
25
+        help='query to build an export list',
26
+    )
27
+    do_query.add_argument(
28
+        'resource_file',
29
+        help='the name of the file listing resources to be updated',
30
+    )
31
+    do_query.set_defaults(func=query_data)
32
+
15 33
 
16 34
 def query_data(cloud, config, args):
17 35
     raise NotImplementedError('query not implemented')

Loading…
Cancel
Save