| 124 | |
| 125 | |
| 126 | class ArgcompleteApp(Application): |
| 127 | name = Unicode("argcomplete-example-app") |
| 128 | description = Unicode("prints requested environment variables") |
| 129 | classes = [JsonPrinter, EnvironPrinter] |
| 130 | |
| 131 | config_file = Unicode("", help="Load this config file").tag(config=True) |
| 132 | |
| 133 | aliases = { |
| 134 | ("e", "env-var", "env-vars"): "EnvironPrinter.vars", |
| 135 | ("s", "style"): "EnvironPrinter.style", |
| 136 | ("json-indent"): "JsonPrinter.indent", |
| 137 | } |
| 138 | |
| 139 | flags = { |
| 140 | "skip-if-missing": bool_flag(EnvironPrinter.skip_if_missing), |
| 141 | } |
| 142 | |
| 143 | def initialize(self, argv=None): |
| 144 | self.parse_command_line(argv) |
| 145 | if self.config_file: |
| 146 | self.load_config_file(self.config_file) |
| 147 | |
| 148 | def start(self): |
| 149 | EnvironPrinter(parent=self).print() |
| 150 | |
| 151 | |
| 152 | if __name__ == "__main__": |