diff --git a/README.md b/README.md index 302cce7..f83e6ba 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Fitbit CLI -[![Release](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml/badge.svg?branch=main&event=release)](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml) [![PyPI - Status](https://img.shields.io/pypi/status/fitbit-cli) +[![Release](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml/badge.svg)](https://github.com/veerendra2/fitbit-cli/actions/workflows/release.yml) [![PyPI - Status](https://img.shields.io/pypi/status/fitbit-cli) ](https://pypi.org/project/fitbit-cli/) [![PyPI - Version](https://img.shields.io/pypi/v/fitbit-cli) ](https://pypi.org/project/fitbit-cli/) @@ -9,9 +9,11 @@ Access your Fitbit data directly from your terminal ๐Ÿ’ป. View ๐Ÿ’ค sleep logs, โค๏ธ heart rate, ๐Ÿ‹๏ธโ€โ™‚๏ธ activity levels, ๐Ÿฉธ SpO2, and more, all presented in a simple, easy-to-read table format!

- Fitbit logo + Fitbit logo

+[![asciicast](https://asciinema.org/a/696114.svg)](https://asciinema.org/a/696114) + ## Supported Web APIs > Only `GET` APIs are supported! @@ -25,11 +27,17 @@ Access your Fitbit data directly from your terminal ๐Ÿ’ป. View ๐Ÿ’ค sleep logs, | [Active Zone Minutes (AZM) Time Series](https://dev.fitbit.com/build/reference/web-api/active-zone-minutes-timeseries/) | โœ… | | [Activity](https://dev.fitbit.com/build/reference/web-api/activity/) | ๐Ÿ‘ท | -## Install +## Usage Guide + +1. Install the Fitbit CLI ```bash python -m pip install fitbit-cli +``` + +2. Help +```bash fitbit-cli -h usage: fitbit-cli [-h] [-i] [-s [DATE[,DATE]]] [-o [DATE[,DATE]]] [-e [DATE[,DATE]]] [-a [DATE[,DATE]]] [-u] [-v] @@ -56,15 +64,38 @@ APIs: Show user profile data ``` -## Register Fitbit App +3. Register Fitbit App -1. Go to [https://dev.fitbit.com/apps](https://dev.fitbit.com/apps) -2. Click on "REGISTER AN APP" tab -3. Follow below example and register an app + 1. Go to [https://dev.fitbit.com/apps](https://dev.fitbit.com/apps) + 2. Click on "REGISTER AN APP" tab + 3. Follow below example and register an app -

- Fitbit logo -

+

+ Fitbit logo +

+ +4. Run the following command to set up interactive authentication and store the Fitbit token locally + + ```bash + fitbit-cli --init-auth + ``` + + For a visual guide, see the Asciinema recording below + [![asciicast](https://asciinema.org/a/696115.svg)](https://asciinema.org/a/696115) + +5. Start using it ๐Ÿ˜Ž + +```bash +$ fitbit-cli -s + Sleep Data Summary ๐Ÿ˜ด +โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ณโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”“ +โ”ƒ Date ๐Ÿ“† โ”ƒ Deep Sleep ๐Ÿ› โ”ƒ Light Sleep ๐Ÿ’ค โ”ƒ REM Sleep ๐ŸŒ™ โ”ƒ Wake Time โฐ โ”ƒ Efficiency ๐Ÿ’ฏ โ”ƒ +โ”กโ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ•‡โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”โ”ฉ +โ”‚ 2024-12-25 โ”‚ 139 min โ”‚ 190 min โ”‚ 155 min โ”‚ 54 min โ”‚ 55% โ”‚ +โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ +``` + +_**NOTE: The token is valid for only 8 hours, `fitbit-cli` automatically refreshes the token when it expires.**_ ## Local Development diff --git a/fitbit_cli/__init__.py b/fitbit_cli/__init__.py index 7ebe120..c530992 100644 --- a/fitbit_cli/__init__.py +++ b/fitbit_cli/__init__.py @@ -3,4 +3,4 @@ fitbit_cli Module """ -__version__ = "1.0.0" +__version__ = "1.1.0" diff --git a/fitbit_cli/cli.py b/fitbit_cli/cli.py index 1d58980..4a74e2e 100644 --- a/fitbit_cli/cli.py +++ b/fitbit_cli/cli.py @@ -95,4 +95,9 @@ def parse_arguments(): help="Show fitbit-cli version", ) - return parser.parse_args() + args = parser.parse_args() + + if not any(vars(args).values()): + parser.error("No arguments provided. At least one argument is required.") + + return args diff --git a/fitbit_cli/fitbit_setup.py b/fitbit_cli/fitbit_setup.py index 047a005..5c8f69c 100644 --- a/fitbit_cli/fitbit_setup.py +++ b/fitbit_cli/fitbit_setup.py @@ -103,7 +103,7 @@ def fitbit_init_setup(): if browser_status: CONSOLE.print( ":satellite: Waiting for authorization... " - + "(Check your browser or press 'Ctrl+C', authrize the app by opening the" + + "(Check your browser or press 'Ctrl+C', authorize the app by opening the" + " above URL in your browser and past the redirect URL manually.)\n" ) authorization_code = start_server() @@ -166,7 +166,7 @@ def fitbit_init_setup(): def read_fitbit_token(): - """Read the Fitbit token from the file and return as a JSON object.""" + """Read Fitbit token from the file and return as a JSON object.""" try: with open(FITBIT_TOKEN_PATH, "r", encoding="utf-8") as f: @@ -184,7 +184,7 @@ def read_fitbit_token(): def write_fitbit_token(token_content): - """Write the Fitbit token to the file.""" + """Write Fitbit token to the file.""" Path(FITBIT_TOKEN_PATH).parent.mkdir(parents=True, exist_ok=True) with open(FITBIT_TOKEN_PATH, "w", encoding="utf-8") as f: @@ -192,7 +192,7 @@ def write_fitbit_token(token_content): def update_fitbit_token(access_token, refresh_token): - """Update the Fitbit token in the file.""" + """Update Fitbit token in the file.""" token_content = read_fitbit_token() token_content["access_token"] = access_token diff --git a/fitbit_cli/main.py b/fitbit_cli/main.py index e8fb311..06b9a07 100644 --- a/fitbit_cli/main.py +++ b/fitbit_cli/main.py @@ -14,7 +14,7 @@ def main(): args = parse_arguments() - if args.init: + if args.init_auth: setup.fitbit_init_setup() credentials = setup.read_fitbit_token() diff --git a/setup.py b/setup.py index e2a9e1d..53a084e 100644 --- a/setup.py +++ b/setup.py @@ -36,15 +36,16 @@ "Intended Audience :: End Users/Desktop", "License :: OSI Approved :: Apache Software License", "Natural Language :: English", + "Operating System :: MacOS", "Operating System :: POSIX :: Linux", - "Programming Language :: Python", - "Programming Language :: Python :: 3", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.9", + "Programming Language :: Python :: 3", + "Programming Language :: Python", "Topic :: Utilities", ], install_requires=[