| 55 | |
| 56 | |
| 57 | class MyApp(Application): |
| 58 | name = Unicode("myapp") |
| 59 | running = Bool(False, help="Is the app running?").tag(config=True) |
| 60 | classes = List([Bar, Foo]) # type:ignore |
| 61 | config_file = Unicode("", help="Load this config file").tag(config=True) |
| 62 | |
| 63 | warn_tpyo = Unicode( |
| 64 | "yes the name is wrong on purpose", |
| 65 | config=True, |
| 66 | help="Should print a warning if `MyApp.warn-typo=...` command is passed", |
| 67 | ) |
| 68 | |
| 69 | aliases: t.Dict[t.Any, t.Any] = {} |
| 70 | aliases.update(Application.aliases) |
| 71 | aliases.update( |
| 72 | { |
| 73 | ("fooi", "i"): "Foo.i", |
| 74 | ("j", "fooj"): ("Foo.j", "`j` terse help msg"), |
| 75 | "name": "Foo.name", |
| 76 | "la": "Foo.la", |
| 77 | "li": "Foo.li", |
| 78 | "tb": "Bar.tb", |
| 79 | "D": "Bar.bdict", |
| 80 | "enabled": "Bar.enabled", |
| 81 | "enable": "Bar.enabled", |
| 82 | "log-level": "Application.log_level", |
| 83 | } |
| 84 | ) |
| 85 | |
| 86 | flags: t.Dict[t.Any, t.Any] = {} |
| 87 | flags.update(Application.flags) |
| 88 | flags.update( |
| 89 | { |
| 90 | ("enable", "e"): ({"Bar": {"enabled": True}}, "Set Bar.enabled to True"), |
| 91 | ("d", "disable"): ({"Bar": {"enabled": False}}, "Set Bar.enabled to False"), |
| 92 | "crit": ({"Application": {"log_level": logging.CRITICAL}}, "set level=CRITICAL"), |
| 93 | } |
| 94 | ) |
| 95 | |
| 96 | def init_foo(self): |
| 97 | self.foo = Foo(parent=self) |
| 98 | |
| 99 | def init_bar(self): |
| 100 | self.bar = Bar(parent=self) |
| 101 | |
| 102 | |
| 103 | def class_to_names(classes): |
searching dependent graphs…