You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2019/04/01 00:58:32 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #4821: [AIRFLOW-3998] Use nested commands in cli.

mik-laj commented on a change in pull request #4821: [AIRFLOW-3998] Use nested commands in cli.
URL: https://github.com/apache/airflow/pull/4821#discussion_r270695422
 
 

 ##########
 File path: airflow/bin/cli.py
 ##########
 @@ -328,34 +348,44 @@ def pool_export_helper(filepath):
 
 
 @cli_utils.action_logging
-def variables(args):
-    if args.get:
-        try:
-            var = Variable.get(args.get,
-                               deserialize_json=args.json,
-                               default_var=args.default)
-            print(var)
-        except ValueError as e:
-            print(e)
-    if args.delete:
-        Variable.delete(args.delete)
-    if args.set:
-        Variable.set(args.set[0], args.set[1])
-    # Work around 'import' as a reserved keyword
-    imp = getattr(args, 'import')
-    if imp:
-        if os.path.exists(imp):
-            import_helper(imp)
-        else:
-            print("Missing variables file.")
-    if args.export:
-        export_helper(args.export)
-    if not (args.set or args.get or imp or args.export or args.delete):
-        # list all variables
-        with db.create_session() as session:
-            vars = session.query(Variable)
-            msg = "\n".join(var.key for var in vars)
-            print(msg)
+def variables_list(args):
+    with db.create_session() as session:
+        vars = session.query(Variable)
+    print("\n".join(var.key for var in vars))
+
+
+@cli_utils.action_logging
+def variables_get(args):
+    try:
+        var = Variable.get(args.key,
+                           deserialize_json=args.json,
+                           default_var=args.default)
+        print(var)
+    except ValueError as e:
+        print(e)
+
+
+@cli_utils.action_logging
+def variables_set(args):
+    Variable.set(args.key, args.value, serialize_json=args.json)
+
+
+@cli_utils.action_logging
+def variables_delete(args):
+    Variable.delete(args.key)
+
+
+@cli_utils.action_logging
+def variables_import(args):
+    if os.path.exists(args.file):
+        import_helper(args.file)
+    else:
+        print("Missing variables file.")
 
 Review comment:
   What error code will be returned here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services