firetest.py
· 230 B · Python
Raw
#!/usr/bin/env python3.6
import fire # pypi.python.org/pypi/fire
class Example:
def hello(self, name="world"):
"""Testing"""
return f"Hello {name}!"
def main():
fire.Fire(Example)
if __name__ == "__main__":
main()
| 1 | #!/usr/bin/env python3.6 |
| 2 | import fire # pypi.python.org/pypi/fire |
| 3 | |
| 4 | class Example: |
| 5 | def hello(self, name="world"): |
| 6 | """Testing""" |
| 7 | return f"Hello {name}!" |
| 8 | |
| 9 | def main(): |
| 10 | fire.Fire(Example) |
| 11 | |
| 12 | if __name__ == "__main__": |
| 13 | main() |
| 1 | $ python3 firetest.py |
| 2 | Type: Example |
| 3 | String form: <__main__.Example object at 0x1028cf470> |
| 4 | File: ~/firetest.py |
| 5 | |
| 6 | Usage: firetest.py |
| 7 | firetest.py hello |
| 8 | |
| 9 | $ python3 firetest.py hello |
| 10 | Hello world! |
| 11 | |
| 12 | $ python3 firetest.py hello there |
| 13 | Hello there! |