{"id":17696794,"url":"https://github.com/datashaman/fly-cli","last_synced_at":"2025-03-31T00:40:43.011Z","repository":{"id":95467581,"uuid":"608022571","full_name":"datashaman/fly-cli","owner":"datashaman","description":"fly","archived":false,"fork":false,"pushed_at":"2023-03-01T22:29:58.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-06T05:43:39.815Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/datashaman.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-01T06:40:47.000Z","updated_at":"2023-03-03T04:23:22.000Z","dependencies_parsed_at":"2023-04-22T18:05:03.221Z","dependency_job_id":null,"html_url":"https://github.com/datashaman/fly-cli","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"1940134418ed76243a12c31cff4b5eb32cc30051"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Ffly-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Ffly-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Ffly-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/datashaman%2Ffly-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/datashaman","download_url":"https://codeload.github.com/datashaman/fly-cli/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246399800,"owners_count":20770907,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-24T14:45:22.588Z","updated_at":"2025-03-31T00:40:42.979Z","avatar_url":"https://github.com/datashaman.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fly-cli\n\nInvoke object methods from the command-line. WIP.\n\n## install\n\nAdd this package to your dependencies in requirements.txt or use pip install:\n\n```\npip install fly-cli\n```\n\n## usage\n\nLet's say you have a class `Greeter` in module `app` (`app.py`) that you want to create a CLI for:\n\n```\nclass Greeter:\n    def greet(name, greeting='hi there'):\n        \"\"\"\n        Greet someone by name.\n\n        :param name: The name of the person to be greeted.\n        :param greeting: The greeting message to use.\n        \"\"\"\n        print(f'{greeting}, {name}')\n```\n\nRun this command to generate a stub:\n\n```\nfly stub app:Greeter greeter\n```\n\nThis will create a binary called `greeter` with the following contents:\n\n```\n#!/usr/bin/env python\nfrom fly_cli import FlyCLI\nfrom app import Greeter\n\n\ndef main():\n    fly = FlyCLI()\n    fly(Greeter())\n\nif __name__ == '__main__':\n    main()\n```\n\nThe `FlyCLI` class inspects the object and generates a sub-command for each method, analysing the method parameters to add arguments to the parser.\n\nNow you can run the script to call an instance of the class:\n\n```\n\u003e ./greeter greet --greeting=\"hola\" bob\nhola, bob\n```\n\nEdit the script to add constructor arguments or configuration if required.\n\nHelp text is generated from method documentation, parsing Sphinx parameter declarations, type declarations and default values to generate argument help.\n\nListing subcommands:\n```\n./greeter --help\nusage: greeter [-h] command ...\n\npositional arguments:\n  command\n    greet     Greet someone by name.\n\noptional arguments:\n  -h, --help  show this help message and exit\n```\n\nSubcommand help:\n```\n\u003e ./greeter greet --help\nusage: greeter greet [-h] [--greeting GREETING] name\n\npositional arguments:\n  name                 The name of the person to be greeted.\n\noptional arguments:\n  -h, --help           show this help message and exit\n  --greeting GREETING  The greeting message to use. Default is \"hi there\".\n```\n\nTo add more subcommands, add more methods on the class.\n\nIf you add type annotations to your parameters, it will coerce the values into the specified type when parsing arguments.\n\nBoolean parameters become string arguments accepting various forms of truthiness: on, off, yes, no, 1, 0, true, false. This is converted to a boolean before the method is called.\n\n`fly-cli` eats its own dogfood, the console script `fly` wraps the `FlyCLI` class.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatashaman%2Ffly-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdatashaman%2Ffly-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdatashaman%2Ffly-cli/lists"}