Updated: Thursday, September 28,2023-09-28 01:14:37
parent
bdea8bd79e
commit
b7178d2899
|
@ -1,5 +1,9 @@
|
||||||
{
|
{
|
||||||
"recentFiles": [
|
"recentFiles": [
|
||||||
|
{
|
||||||
|
"basename": "Fire",
|
||||||
|
"path": "Fire.md"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"basename": "1.About Languages",
|
"basename": "1.About Languages",
|
||||||
"path": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md"
|
"path": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md"
|
||||||
|
@ -195,10 +199,6 @@
|
||||||
{
|
{
|
||||||
"basename": "Trunked Radio",
|
"basename": "Trunked Radio",
|
||||||
"path": "Coding Tips (Classical)/Project Vault/Communication Projects/RADIO/Software/Trunked Radio.md"
|
"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": [],
|
"omittedPaths": [],
|
||||||
|
|
|
@ -26,9 +26,21 @@
|
||||||
"source": false
|
"source": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "82726a166dd2a829",
|
||||||
|
"type": "leaf",
|
||||||
|
"state": {
|
||||||
|
"type": "markdown",
|
||||||
|
"state": {
|
||||||
|
"file": "Fire.md",
|
||||||
|
"mode": "source",
|
||||||
|
"source": false
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"currentTab": 1
|
"currentTab": 2
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"direction": "vertical"
|
"direction": "vertical"
|
||||||
|
@ -102,7 +114,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "outgoing-link",
|
"type": "outgoing-link",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md",
|
"file": "Fire.md",
|
||||||
"linksCollapsed": false,
|
"linksCollapsed": false,
|
||||||
"unlinkedCollapsed": true
|
"unlinkedCollapsed": true
|
||||||
}
|
}
|
||||||
|
@ -135,7 +147,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "outline",
|
"type": "outline",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md"
|
"file": "Fire.md"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -145,7 +157,7 @@
|
||||||
"state": {
|
"state": {
|
||||||
"type": "backlink",
|
"type": "backlink",
|
||||||
"state": {
|
"state": {
|
||||||
"file": "Coding Tips (Classical)/Terminal Tips/Languages/1.About Languages.md",
|
"file": "Fire.md",
|
||||||
"collapseAll": false,
|
"collapseAll": false,
|
||||||
"extraContext": false,
|
"extraContext": false,
|
||||||
"sortOrder": "alphabetical",
|
"sortOrder": "alphabetical",
|
||||||
|
@ -177,8 +189,10 @@
|
||||||
"command-palette:Open command palette": false
|
"command-palette:Open command palette": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"active": "c9cd512fcf3f7b9e",
|
"active": "82726a166dd2a829",
|
||||||
"lastOpenFiles": [
|
"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/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/ASCII.md",
|
||||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Commands + Settings/Aliases.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)/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/Languages/Go/Welcome to Go.md",
|
||||||
"Coding Tips (Classical)/Terminal Tips/CLI Tools/CLI Tool Collection/Mods.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/VirtualBox",
|
||||||
"Coding Tips (Classical)/Terminal Tips/Servers/Virtual Machines/Quay",
|
"Coding Tips (Classical)/Terminal Tips/Servers/Virtual Machines/Quay",
|
||||||
"Coding Tips (Classical)/Project Vault/Website Projects/Obsidian/imgFiles/Pasted image 20230924025824.png",
|
"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