xonecas.ioDon't click! Sean Caetano Martin Sign in
cast / src / settings / mod.rs 32 lines837 bytes Raw
1pub mod view;
2
3use crate::app::App;
4use crate::config::Config;
5use rune::TextEdit;
6
7pub struct Form {
8    pub claude: TextEdit,
9    pub opencode: TextEdit,
10    pub model: TextEdit,
11    pub paste_claude: bool,
12}
13
14impl Form {
15    pub fn new(cfg: &Config) -> Form {
16        Form {
17            claude: TextEdit::new(&cfg.claude_token),
18            opencode: TextEdit::new(&cfg.opencode_key),
19            model: TextEdit::new(&cfg.opencode_model),
20            paste_claude: !cfg.claude_token.is_empty(),
21        }
22    }
23}
24
25impl App {
26    pub fn save_settings(&mut self) {
27        self.cfg.claude_token = self.settings.claude.text.trim().to_string();
28        self.cfg.opencode_key = self.settings.opencode.text.trim().to_string();
29        self.cfg.opencode_model = self.settings.model.text.trim().to_string();
30        self.cfg.save();
31    }
32}