- "text": "Python Fire\n\n\nPython Fire is a library for automatically generating command line interfaces\n(CLIs) from absolutely any Python object.\n\n\n\n\nPython Fire is a simple way to create a CLI in Python. \n[1]\n\n\nPython Fire is a helpful tool for developing and debugging Python code. \n[2]\n\n\nPython Fire helps with exploring existing code or turning other people's code\ninto a CLI. \n[3]\n\n\nPython Fire makes transitioning between Bash and Python easier. \n[4]\n\n\nPython Fire makes using a Python REPL easier by setting up the REPL with the\nmodules and variables you'll need already imported and created. \n[5]\n\n\n\n\nInstallation\n\n\nTo install Python Fire with pip, run: \npip install fire\n\n\nTo install Python Fire with conda, run: \nconda install fire -c conda-forge\n\n\nTo install Python Fire from source, first clone the repository and then run:\n\npython setup.py install\n\n\nBasic Usage\n\n\nYou can call \nFire\n on any Python object:\n\nfunctions, classes, modules, objects, dictionaries, lists, tuples, etc.\nThey all work!\n\n\nHere's an example of calling Fire on a class.\n\n\nimport fire\n\nclass Calculator(object):\n \nA simple calculator class.\n\n\n def double(self, number):\n return 2 * number\n\nif __name__ == '__main__':\n fire.Fire(Calculator)\n\n\n\n\nThen, from the command line, you can run:\n\n\npython calculator.py double 10 # 20\npython calculator.py double --number=15 # 30\n\n\n\n\nTo learn how Fire behaves on functions, objects, dicts, lists, etc, and to learn\nabout Fire's other features, see the \nUsing a Fire CLI page\n.\n\n\nFor additional examples, see \nThe Python Fire Guide\n.\n\n\nWhy is it called Fire?\n\n\nWhen you call \nFire\n, it fires off (executes) your command.\n\n\nWhere can I learn more?\n\n\nPlease see \nThe Python Fire Guide\n.\n\n\nReference\n\n\n\n\n\n\n\n\nSetup\n\n\nCommand\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\ninstall\n\n\npip install fire\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nCreating a CLI\n\n\nCommand\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nimport\n\n\nimport fire\n\n\n\n\n\n\n\n\nCall\n\n\nfire.Fire()\n\n\nTurns the current module into a Fire CLI.\n\n\n\n\n\n\nCall\n\n\nfire.Fire(component)\n\n\nTurns \ncomponent\n into a Fire CLI.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nUsing a CLI\n\n\nCommand\n\n\nNotes\n\n\n\n\n\n\n\n\n\n\nHelp\n\n\ncommand -- --help\n\n\n\n\n\n\n\n\nREPL\n\n\ncommand -- --interactive\n\n\nEnters interactive mode.\n\n\n\n\n\n\nSeparator\n\n\ncommand -- --separator=X\n\n\nThis sets the separator to \nX\n. The default separator is \n-\n.\n\n\n\n\n\n\nCompletion\n\n\ncommand -- --completion\n\n\nGenerate a completion script for the CLI.\n\n\n\n\n\n\nTrace\n\n\ncommand -- --trace\n\n\nGets a Fire trace for the command.\n\n\n\n\n\n\nVerbose\n\n\ncommand -- --verbose\n\n\n\n\n\n\n\n\n\n\nNote that flags are separated from the Fire command by an isolated \n--\n arg.\n\n\nDisclaimer\n\n\nThis is not an official Google product.",
0 commit comments