Updated: Thursday, September 28,2023-09-28 01:14:37
parent
bdea8bd79e
commit
b7178d2899
|
@ -1,5 +1,9 @@
|
|||
{
|
||||
"recentFiles": [
|
||||
{
|
||||
"basename": "Fire",
|
||||
"path": "Fire.md"
|
||||
},
|
||||
{
|
||||
"basename": "1.About Languages",
|
||||
"path": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md"
|
||||
|
@ -195,10 +199,6 @@
|
|||
{
|
||||
"basename": "Trunked Radio",
|
||||
"path": "Coding Tips (Classical)/Project Vault/Communication Projects/RADIO/Software/Trunked Radio.md"
|
||||
},
|
||||
{
|
||||
"basename": "Radio @ K2HMH",
|
||||
"path": "Coding Tips (Classical)/Project Vault/Communication Projects/RADIO/HM Wiki/Radio @ K2HMH.md"
|
||||
}
|
||||
],
|
||||
"omittedPaths": [],
|
||||
|
|
|
@ -26,9 +26,21 @@
|
|||
"source": false
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "82726a166dd2a829",
|
||||
"type": "leaf",
|
||||
"state": {
|
||||
"type": "markdown",
|
||||
"state": {
|
||||
"file": "Fire.md",
|
||||
"mode": "source",
|
||||
"source": false
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"currentTab": 1
|
||||
"currentTab": 2
|
||||
}
|
||||
],
|
||||
"direction": "vertical"
|
||||
|
@ -102,7 +114,7 @@
|
|||
"state": {
|
||||
"type": "outgoing-link",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md",
|
||||
"file": "Fire.md",
|
||||
"linksCollapsed": false,
|
||||
"unlinkedCollapsed": true
|
||||
}
|
||||
|
@ -135,7 +147,7 @@
|
|||
"state": {
|
||||
"type": "outline",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md"
|
||||
"file": "Fire.md"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -145,7 +157,7 @@
|
|||
"state": {
|
||||
"type": "backlink",
|
||||
"state": {
|
||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md",
|
||||
"file": "Fire.md",
|
||||
"collapseAll": false,
|
||||
"extraContext": false,
|
||||
"sortOrder": "alphabetical",
|
||||
|
@ -177,8 +189,10 @@
|
|||
"command-palette:Open command palette": false
|
||||
}
|
||||
},
|
||||
"active": "c9cd512fcf3f7b9e",
|
||||
"active": "82726a166dd2a829",
|
||||
"lastOpenFiles": [
|
||||
"Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md",
|
||||
"Fire.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Commands + Settings/Command Shortcuts.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Commands + Settings/ASCII.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Commands + Settings/Aliases.md",
|
||||
|
@ -204,8 +218,6 @@
|
|||
"Coding Tips (Classical)/Project Vault/Communication Projects/RADIO/Hardware/Optical Network Terminals.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/Languages/Go/Welcome to Go.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Mods.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/Languages/Documentation.md",
|
||||
"Coding Tips (Classical)/Project Vault/Website Projects/Obsidian/Obsidian Guides/Notable Obsidians.md",
|
||||
"Coding Tips (Classical)/Terminal Tips/Servers/Virtual Machines/VirtualBox",
|
||||
"Coding Tips (Classical)/Terminal Tips/Servers/Virtual Machines/Quay",
|
||||
"Coding Tips (Classical)/Project Vault/Website Projects/Obsidian/imgFiles/Pasted image 20230924025824.png",
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
|
||||
Python [fire](https://github.com/google/python-fire) is extremely useful for automatically generating command line interfaces (CLIs) from absolutely any Python object.
|
||||
|
||||
Examples:
|
||||
|
||||
The python class:
|
||||
```python
|
||||
import fire
|
||||
|
||||
class Calculator(object):
|
||||
"""A simple calculator class."""
|
||||
|
||||
def double(self, number):
|
||||
return 2 * number
|
||||
|
||||
if __name__ == '__main__':
|
||||
fire.Fire(Calculator)
|
||||
```
|
||||
|
||||
Then, when calling the file on the terminal, the CLI is already there:
|
||||
```shell
|
||||
python calculator.py double 10 # 20
|
||||
python calculator.py double --number=15 # 30
|
||||
```
|
Loading…
Reference in New Issue