Skip to content

Commit b42a9e1

Browse files
authored
Fix cli (#7)
* Fix cli * Add macos pypi classifier * Add macos pypi classifier * Add at least one argument is required * Add asciinema recording * Fix typos * Fix typos
1 parent a92614d commit b42a9e1

File tree

6 files changed

+57
-20
lines changed

6 files changed

+57
-20
lines changed

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Fitbit CLI
22

3-
[![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)
3+
[![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)
44
](https://pypi.org/project/fitbit-cli/) [![PyPI - Version](https://img.shields.io/pypi/v/fitbit-cli)
55
](https://pypi.org/project/fitbit-cli/)
66

@@ -9,9 +9,11 @@
99
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!
1010

1111
<p align="center">
12-
<img alt="Fitbit logo", width="250" src="./assets/Fitbit_Logo_White_RGB.jpg">
12+
<img alt="Fitbit logo", width="250" src="https://raw.githubusercontent.com/veerendra2/fitbit-cli/refs/heads/main/assets/Fitbit_Logo_White_RGB.jpg">
1313
</p>
1414

15+
[![asciicast](https://asciinema.org/a/696114.svg)](https://asciinema.org/a/696114)
16+
1517
## Supported Web APIs
1618

1719
> Only `GET` APIs are supported!
@@ -25,11 +27,17 @@ Access your Fitbit data directly from your terminal 💻. View 💤 sleep logs,
2527
| [Active Zone Minutes (AZM) Time Series](https://dev.fitbit.com/build/reference/web-api/active-zone-minutes-timeseries/) ||
2628
| [Activity](https://dev.fitbit.com/build/reference/web-api/activity/) | 👷 |
2729

28-
## Install
30+
## Usage Guide
31+
32+
1. Install the Fitbit CLI
2933

3034
```bash
3135
python -m pip install fitbit-cli
36+
```
37+
38+
2. Help
3239

40+
```bash
3341
fitbit-cli -h
3442
usage: fitbit-cli [-h] [-i] [-s [DATE[,DATE]]] [-o [DATE[,DATE]]] [-e [DATE[,DATE]]] [-a [DATE[,DATE]]] [-u] [-v]
3543

@@ -56,15 +64,38 @@ APIs:
5664
Show user profile data
5765
```
5866
59-
## Register Fitbit App
67+
3. Register Fitbit App
6068
61-
1. Go to [https://dev.fitbit.com/apps](https://dev.fitbit.com/apps)
62-
2. Click on "REGISTER AN APP" tab
63-
3. Follow below example and register an app
69+
1. Go to [https://dev.fitbit.com/apps](https://dev.fitbit.com/apps)
70+
2. Click on "REGISTER AN APP" tab
71+
3. Follow below example and register an app
6472
65-
<p align="left">
66-
<img alt="Fitbit logo", width="700" src="./assets/fitbit-app-registration.png">
67-
</p>
73+
<p align="left">
74+
<img alt="Fitbit logo", width="700" src="https://raw.githubusercontent.com/veerendra2/fitbit-cli/refs/heads/main/assets/fitbit-app-registration.png">
75+
</p>
76+
77+
4. Run the following command to set up interactive authentication and store the Fitbit token locally
78+
79+
```bash
80+
fitbit-cli --init-auth
81+
```
82+
83+
For a visual guide, see the Asciinema recording below
84+
[![asciicast](https://asciinema.org/a/696115.svg)](https://asciinema.org/a/696115)
85+
86+
5. Start using it 😎
87+
88+
```bash
89+
$ fitbit-cli -s
90+
Sleep Data Summary 😴
91+
┏━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━┓
92+
┃ Date 📆 ┃ Deep Sleep 🛏 ┃ Light Sleep 💤 ┃ REM Sleep 🌙 ┃ Wake Time ⏰ ┃ Efficiency 💯 ┃
93+
┡━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━┩
94+
│ 2024-12-25 │ 139 min │ 190 min │ 155 min │ 54 min │ 55% │
95+
└────────────┴──────────────┴────────────────┴──────────────┴──────────────┴───────────────┘
96+
```
97+
98+
_**NOTE: The token is valid for only 8 hours, `fitbit-cli` automatically refreshes the token when it expires.**_
6899
69100
## Local Development
70101

fitbit_cli/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
fitbit_cli Module
44
"""
55

6-
__version__ = "1.0.0"
6+
__version__ = "1.1.0"

fitbit_cli/cli.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,9 @@ def parse_arguments():
9595
help="Show fitbit-cli version",
9696
)
9797

98-
return parser.parse_args()
98+
args = parser.parse_args()
99+
100+
if not any(vars(args).values()):
101+
parser.error("No arguments provided. At least one argument is required.")
102+
103+
return args

fitbit_cli/fitbit_setup.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def fitbit_init_setup():
103103
if browser_status:
104104
CONSOLE.print(
105105
":satellite: Waiting for authorization... "
106-
+ "(Check your browser or press 'Ctrl+C', authrize the app by opening the"
106+
+ "(Check your browser or press 'Ctrl+C', authorize the app by opening the"
107107
+ " above URL in your browser and past the redirect URL manually.)\n"
108108
)
109109
authorization_code = start_server()
@@ -166,7 +166,7 @@ def fitbit_init_setup():
166166

167167

168168
def read_fitbit_token():
169-
"""Read the Fitbit token from the file and return as a JSON object."""
169+
"""Read Fitbit token from the file and return as a JSON object."""
170170

171171
try:
172172
with open(FITBIT_TOKEN_PATH, "r", encoding="utf-8") as f:
@@ -184,15 +184,15 @@ def read_fitbit_token():
184184

185185

186186
def write_fitbit_token(token_content):
187-
"""Write the Fitbit token to the file."""
187+
"""Write Fitbit token to the file."""
188188

189189
Path(FITBIT_TOKEN_PATH).parent.mkdir(parents=True, exist_ok=True)
190190
with open(FITBIT_TOKEN_PATH, "w", encoding="utf-8") as f:
191191
json.dump(token_content, f)
192192

193193

194194
def update_fitbit_token(access_token, refresh_token):
195-
"""Update the Fitbit token in the file."""
195+
"""Update Fitbit token in the file."""
196196

197197
token_content = read_fitbit_token()
198198
token_content["access_token"] = access_token

fitbit_cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def main():
1414

1515
args = parse_arguments()
1616

17-
if args.init:
17+
if args.init_auth:
1818
setup.fitbit_init_setup()
1919

2020
credentials = setup.read_fitbit_token()

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,16 @@
3636
"Intended Audience :: End Users/Desktop",
3737
"License :: OSI Approved :: Apache Software License",
3838
"Natural Language :: English",
39+
"Operating System :: MacOS",
3940
"Operating System :: POSIX :: Linux",
40-
"Programming Language :: Python",
41-
"Programming Language :: Python :: 3",
4241
"Programming Language :: Python :: 3 :: Only",
43-
"Programming Language :: Python :: 3.9",
4442
"Programming Language :: Python :: 3.10",
4543
"Programming Language :: Python :: 3.11",
4644
"Programming Language :: Python :: 3.12",
4745
"Programming Language :: Python :: 3.13",
46+
"Programming Language :: Python :: 3.9",
47+
"Programming Language :: Python :: 3",
48+
"Programming Language :: Python",
4849
"Topic :: Utilities",
4950
],
5051
install_requires=[

0 commit comments

Comments
 (0)