Skip to content

Commit

Permalink
docs: updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Jul 10, 2024
1 parent 8ff1e2c commit 5555036
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 7 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ The dump command downloads **all your Whoop data** and saves it to a local file.
mywhoop dump
```

| Flag | Description | Required | Default |
|---|----|---|---|
| `--location` | The location to save the Whoop data file. | No | `./data/` |


### Login

Expand Down
32 changes: 27 additions & 5 deletions cmd/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ import (
"github.com/spf13/cobra"
)

// meCmd represents the me command
var meCmd = &cobra.Command{
var dataLocation string

var dumpCmd = &cobra.Command{
Use: "dump",
Short: "Dump all your Whoop data to a file or another form of export.",
Long: "Dump all your Whoop data to a file or another form of export.",
Expand All @@ -29,7 +30,8 @@ var meCmd = &cobra.Command{
}

func init() {
rootCmd.AddCommand(meCmd)
dumpCmd.PersistentFlags().StringVarP(&dataLocation, "location", "l", "", "The location to dump the data to. Default is the current directory's data/ folder.")
rootCmd.AddCommand(dumpCmd)
}

func dump(ctx context.Context) error {
Expand Down Expand Up @@ -161,10 +163,18 @@ func dump(ctx context.Context) error {
}
return err
}
var filePath string

switch cfg.Export.Method {
case "file":
fileExp := export.NewFileExport(Configuration.Export.FileExport.FilePath,

if dataLocation == "" {
filePath = Configuration.Export.FileExport.FilePath
} else {
filePath = dataLocation
}

fileExp := export.NewFileExport(filePath,
Configuration.Export.FileExport.FileType,
Configuration.Export.FileExport.FileName,
Configuration.Export.FileExport.FileNamePrefix,
Expand All @@ -180,6 +190,11 @@ func dump(ctx context.Context) error {
}
slog.Info("Data exported successfully", "file", fileExp.FileName)
case "s3":

if dataLocation != "" {
cfg.Export.AWSS3.FileConfig.FilePath = dataLocation
}

awsS3, err := export.NewAwsS3Export(cfg.Export.AWSS3.Region,
cfg.Export.AWSS3.Bucket,
cfg.Export.AWSS3.Profile,
Expand All @@ -200,8 +215,15 @@ func dump(ctx context.Context) error {
}

default:

if dataLocation == "" {
filePath = Configuration.Export.FileExport.FilePath
} else {
filePath = dataLocation
}

slog.Info("no export method specified. Defaulting to file.")
fileExp := export.NewFileExport(Configuration.Export.FileExport.FilePath,
fileExp := export.NewFileExport(filePath,
Configuration.Export.FileExport.FileType,
Configuration.Export.FileExport.FileName,
Configuration.Export.FileExport.FileNamePrefix,
Expand Down
48 changes: 46 additions & 2 deletions docs/get-started.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Get Starrted
# Get Started

MyWhoop requires a few one-time setup steps to get started. The primary steps include setting up a Whoop application in the Whoop Developer Portal and setting up MyWhoop on your local machine or server. Once you have completed these steps, you can start using MyWhoop to interact with your Whoop data as you see fit.

Expand Down Expand Up @@ -97,4 +97,48 @@ The following steps will guide you through the process of setting up MyWhoop on

![A view of the MyWhoop login page](../static/images/tutorial_4.png)

12. Click on **Close Application** and close the browser tab.
12. Click on **Close Application** and close the browser tab.

> [!NOTE]
> The authentication token is valid for 1 hour. If the token expires, you will need to re-authenticate with the Whoop API. You can use the `login` command to create a new token.


13. Issue the MyWhoop `dump` command to download all your Whoop data and save it to a local file. The `--location` flag is used to specify the location to save the Whoop data file.

```shell
docker run --publish 8080:8080 --volume $PWD:/app -e WHOOP_CLIENT_ID=$WHOOP_CLIENT_ID -e WHOOP_CLIENT_SECRET=$WHOOP_CLIENT_SECRET ghcr.io/karl-cardenas-coding/mywhoop:v1.0.0 dump --credentials /app/token.json --location /app
```

Upon successful download, the Whoop data will be saved in the `~/mywhoop/data/` directory. The final output will look similar to the following:

```
time="2024/07/09 23:51:52" level=INFO msg="data written to file" file=/app/user.json
time="2024/07/09 23:51:52" level=INFO msg="All Whoop data downloaded successfully"
```

14. To review the downloaded data, navigate to the `~/mywhoop/data` directory and open the `user.json` file. The file contains all the Whoop data downloaded from the Whoop API.

```shell
cat ~/mywhoop/data/user.json | jq
```

```json
{
"user_data": {
"user_id": 11111111,
"email": "[email protected]",
"first_name": "John",
"last_name": "Doe "
},
"user_mesaurements": {
"height_meter": 1.48,
"weight_kilogram": 66.678085,
"max_heart_rate": 198
},
...// Additional data follows
}
```



15. You have successfully set up MyWhoop on your local machine or server. You can now use MyWhoop to interact with your Whoop data as needed. For more information on the available commands and options, refer to the [Commands Reference](./commands_reference.md) section.

0 comments on commit 5555036

Please sign in to comment.