@@ -61,7 +61,56 @@ def get_meta_path(root_node, rel_path=None, meta_key=False):
61
61
62
62
def main ():
63
63
"""Implement the "rose config" command."""
64
- opt_parser = RoseOptionParser ()
64
+ opt_parser = RoseOptionParser (
65
+ description = '''
66
+ Parse and print rose configuration files.
67
+
68
+ With no option and no argument, print the rose site + user configuration.
69
+
70
+ EXAMPLES
71
+ # Print the value of OPTION in SECTION.
72
+ rose config SECTION OPTION
73
+
74
+ # Print the value of OPTION in SECTION in FILE.
75
+ rose config --file=FILE SECTION OPTION
76
+
77
+ # Print the value of OPTION in SECTION if exists, or VALUE otherwise.
78
+ rose config --default=VALUE SECTION OPTION
79
+
80
+ # Print the OPTION=VALUE pairs in SECTION.
81
+ rose config SECTION
82
+
83
+ # Print the value of a top level OPTION.
84
+ rose config OPTION
85
+
86
+ # Print the OPTION keys in SECTION.
87
+ rose config --keys SECTION
88
+
89
+ # Print the SECTION keys.
90
+ rose config --keys
91
+
92
+ # Exit with 0 if OPTION exists in SECTION, or 1 otherwise.
93
+ rose config -q SECTION OPTION
94
+
95
+ # Exit with 0 if SECTION exists, or 1 otherwise.
96
+ rose config -q SECTION
97
+
98
+ # Combine the configurations in FILE1 and FILE2, and dump the result.
99
+ rose config --file=FILE1 --file=FILE2
100
+
101
+ # Print the value of OPTION in SECTION of the metadata associated with
102
+ # the specified config FILE
103
+ rose config --file=FILE --meta SECTION OPTION
104
+
105
+ # Print the value of a specified metadata KEY
106
+ rose config --meta-key=KEY
107
+ ''' ,
108
+ epilog = '''
109
+ ENVIRONMENT VARIABLES
110
+ optional ROSE_META_PATH
111
+ Prepend `$ROSE_META_PATH` to the metadata search path.
112
+ '''
113
+ )
65
114
opt_parser .add_my_options (
66
115
"default" ,
67
116
"env_var_process_mode" ,
@@ -73,9 +122,17 @@ def main():
73
122
"no_opts" ,
74
123
"print_conf_mode" ,
75
124
)
125
+ # the quietness argument is non-standard for this command
126
+ opt_parser .modify_option (
127
+ 'quietness' ,
128
+ help = (
129
+ "Exit with 0 if the specified `SECTION` and/or `OPTION` exist in"
130
+ " the configuration, or 1 otherwise."
131
+ ),
132
+ )
133
+
76
134
opts , args = opt_parser .parse_args ()
77
135
report = Reporter (opts .verbosity - opts .quietness )
78
-
79
136
metomi .rose .macro .add_meta_paths ()
80
137
81
138
if opts .meta_key :
0 commit comments