Skip to content

Commit

Permalink
[chore] Add Startup Docs (#77)
Browse files Browse the repository at this point in the history
* add docs and default api_key value for coingecko

* fix
  • Loading branch information
warittornc authored Oct 15, 2024
1 parent df1041b commit a07349b
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bothan-coingecko/src/worker/opts.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::time::Duration;

use serde::{Deserialize, Serialize};
use serde::{Deserialize, Deserializer, Serialize, Serializer};

use crate::api::types::{DEFAULT_URL, DEFAULT_USER_AGENT};
use crate::worker::types::DEFAULT_UPDATE_INTERVAL;
Expand All @@ -15,6 +15,8 @@ pub struct CoinGeckoWorkerBuilderOpts {
#[serde(default = "default_url")]
pub url: String,
#[serde(default)]
#[serde(deserialize_with = "empty_string_is_none")]
#[serde(serialize_with = "none_is_empty_string")]
pub api_key: Option<String>,
#[serde(default = "default_user_agent")]
pub user_agent: String,
Expand Down Expand Up @@ -45,3 +47,20 @@ impl Default for CoinGeckoWorkerBuilderOpts {
}
}
}

fn empty_string_is_none<'de, D: Deserializer<'de>>(
deserializer: D,
) -> Result<Option<String>, D::Error> {
let s: Option<String> = Option::deserialize(deserializer)?;
Ok(s.filter(|s| !s.is_empty()))
}

fn none_is_empty_string<S: Serializer>(
value: &Option<String>,
serializer: S,
) -> Result<S::Ok, S::Error> {
match value {
Some(val) => serializer.serialize_str(val),
None => serializer.serialize_str(""),
}
}
52 changes: 52 additions & 0 deletions docs/setup_bothan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Bothan Installation Guide

## Prerequisites

Before building and running Bothan, ensure the following dependencies are installed:

- [Clang](https://clang.llvm.org/get_started.html)
- [Rust](https://www.rust-lang.org/tools/install)

## Building Bothan

To install the Bothan CLI, follow the steps below:

- Clone or navigate to the bothan-api repository.
- Run the following command to build and install the Bothan CLI
binary:

```bash
cargo install --path bothan-api/server-cli --bin bothan
```

This will compile and install the bothan executable

## Configuration Setup

Once Bothan is installed, the next step is to initialize the configuration file. By default, the configuration file will
be created in the `$HOME/.bothan` directory.

- Initialize the configuration file using the command:

```bash
bothan config init
```

- Open the configuration file in any text editor of your choice and adjust the parameters as necessary

## Starting Bothan

After the configuration is set up, you can start Bothan by running:

```bash
bothan start
```

### Optional: Specify Config File Path

If the configuration file is not located in the default directory `$HOME/.bothan/`, use the --config flag to specify the
path to the configuration file:

```bash
bothan start --config /path/to/config.toml
```

0 comments on commit a07349b

Please sign in to comment.