aboutsummaryrefslogtreecommitdiffstats
path: root/devtools/ya/handlers/gen_config/__init__.py
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2023-12-02 01:45:21 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2023-12-02 02:42:50 +0300
commit9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c (patch)
tree9f88a486917d371d099cd712efd91b4c122d209d /devtools/ya/handlers/gen_config/__init__.py
parent32fb6dda1feb24f9ab69ece5df0cb9ec238ca5e6 (diff)
downloadydb-9c43d58f75cf086b744cf4fe2ae180e8f37e4a0c.tar.gz
Intermediate changes
Diffstat (limited to 'devtools/ya/handlers/gen_config/__init__.py')
-rw-r--r--devtools/ya/handlers/gen_config/__init__.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/devtools/ya/handlers/gen_config/__init__.py b/devtools/ya/handlers/gen_config/__init__.py
new file mode 100644
index 0000000000..e771dac871
--- /dev/null
+++ b/devtools/ya/handlers/gen_config/__init__.py
@@ -0,0 +1,48 @@
+from __future__ import absolute_import
+import core.common_opts
+import core.yarg
+
+from . import gen_config
+
+
+class GenConfigOptions(core.yarg.Options):
+ def __init__(self):
+ self.output = None
+ self.dump_defaults = False
+
+ @staticmethod
+ def consumer():
+ return [
+ core.yarg.SingleFreeArgConsumer(
+ help='ya.conf',
+ hook=core.yarg.SetValueHook('output'),
+ required=False,
+ ),
+ core.yarg.ArgConsumer(
+ ['--dump-defaults'],
+ help='Dump default values as JSON',
+ hook=core.yarg.SetConstValueHook('dump_defaults', True),
+ ),
+ ]
+
+
+class GenConfigYaHandler(core.yarg.OptsHandler):
+ description = 'Generate default ya config'
+
+ def __init__(self):
+ self._root_handler = None
+ super(GenConfigYaHandler, self).__init__(
+ action=self.do_generate,
+ description=self.description,
+ opts=[
+ core.common_opts.ShowHelpOptions(),
+ GenConfigOptions(),
+ ],
+ )
+
+ def handle(self, root_handler, args, prefix):
+ self._root_handler = root_handler
+ super(GenConfigYaHandler, self).handle(root_handler, args, prefix)
+
+ def do_generate(self, args):
+ gen_config.generate_config(self._root_handler, args.output, args.dump_defaults)