1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
use std::process::Command;

pub struct ApiTokenAddCommand {
    command: Command,
}

impl ApiTokenAddCommand {
    pub fn new(command: Command) -> Self {
        Self { command }
    }

    pub fn db_url<S: Into<String>>(mut self, db_url: S) -> Self {
        self.command.arg("--db-url").arg(db_url.into());
        self
    }

    pub fn tokens(mut self, tokens: &[String]) -> Self {
        self = self.tokens_as_str(&tokens.join(","));
        self
    }

    pub fn tokens_as_str(mut self, tokens: &str) -> Self {
        self.command.arg("--tokens").arg(tokens);
        self
    }

    pub fn build(self) -> Command {
        self.command
    }
}