kutt 0.0.2

command line tool for kutt.it service
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use crate::constants::*;
use crate::errors::*;
use crate::utils::*;
use std::env;

pub struct ApiKey;

impl ApiKey {
    pub fn get() -> Result<String> {
        env::var("KUTT_API_KEY")
            .or_else(|_| read_file(&*PATH_FILE_API_KEY))
            .map(|key| key.trim().to_owned())
    }
    #[allow(dead_code)]
    pub fn set(key: &str) -> Result {
        write_file(&*PATH_FILE_API_KEY, key)
    }
}