Exemple #1
0
 def test_with_domain(self):
     """Test with domain action."""
     with flags.Subcommand("dummy_action", dest="action"):
         # test default value.
         FLAGS._parse_flags(["move", "dummy_object"])  # pylint: disable=protected-access
         self.assertEqual("move", FLAGS.action)
         self.assertEqual("default", FLAGS.move_string)
         self.assertTrue(FLAGS.move_bool)
Exemple #2
0
"""Test helper for smoke_test.sh."""

# Similar to https://github.com/abseil/abseil-py/blob/master/smoke_tests/smoke_test.py

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import smile as sm
from smile import flags
from smile import logging

flags.DEFINE_string("param", "default_value", "A general flag.")

with flags.Subcommand("echo", dest="action"):
    flags.DEFINE_string("echo_text", "", "The text to be echoed out.")

with flags.Subcommand("echo_bool", dest="action"):
    flags.DEFINE_bool("just_do_it", False, "some help infomation")

FLAGS = flags.FLAGS


def main(_):
    """Print out the FLAGS in the main function."""
    logging.info("param = %s", FLAGS.param)
    if FLAGS.action == "echo":
        logging.warning(FLAGS.echo_text)
    elif FLAGS.action == "echo_bool":
        logging.info("Just do it? %s", "Yes!" if FLAGS.just_do_it else "No :(")
Exemple #3
0
from smile import flags

flags.DEFINE_string("string_foo", "default_val", "HelpString")
flags.DEFINE_integer("int_foo", 42, "HelpString")
flags.DEFINE_float("float_foo", 42.0, "HelpString")

flags.DEFINE_boolean("bool_foo", True, "HelpString")
flags.DEFINE_boolean("bool_negation", True, "HelpString")
flags.DEFINE_boolean("bool-dash-negation", True, "HelpString")
flags.DEFINE_boolean("bool_a", False, "HelpString")
flags.DEFINE_boolean("bool_c", False, "HelpString")
flags.DEFINE_boolean("bool_d", True, "HelpString")
flags.DEFINE_bool("bool_e", True, "HelpString")

with flags.Subcommand("dummy_action", dest="action"):
    pass

with flags.Subcommand("move", dest="action"):
    flags.DEFINE_string("move_string", "default", "help")
    flags.DEFINE_bool("move_bool", True, "HelpString")

    with flags.Subcommand("dummy_object", dest="object"):
        pass

    with flags.Subcommand("wa", dest="object"):
        flags.DEFINE_string("move_wa_string", "default_wa", "help")
        flags.DEFINE_bool("move_wa_bool", False, "HelpString")

with flags.Subcommand("require", dest="action"):
    flags.DEFINE_string("string_foo_required",