| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | | use super::repo::Quickstart; |
| 6 | | use super::{Page, Shell}; |
| 7 | | use crate::auth::Viewer; |
| 8 | | use crate::Shared; |
| 9 | | use askama::Template; |
| 10 | | use axum::extract::State; |
| 11 | |
|
| 12 | | #[derive(Template)] |
| 13 | | #[template(path = "help.html")] |
| 14 | | pub struct HelpPage { |
| 15 | | shell: Shell, |
| 16 | | q: Quickstart, |
| 17 | | base: String, |
| 18 | | |
| 19 | | who: String, |
| 20 | | } |
| 21 | |
|
| 22 | 1× | pub async fn help(State(app): State<Shared>, viewer: Viewer) -> Page<HelpPage> { |
| 23 | 1× | let shell = Shell::new(&app, "/help", &viewer); |
| 24 | 1× | let who = shell.user.clone().unwrap_or_else(|| "OWNER".into()); |
| 25 | 1× | let base = app.config.base_url().trim_end_matches('/').to_string(); |
| 26 | 1× | Page(HelpPage { shell, q: Quickstart::new(&app, true), base, who }) |
| 27 | 1× | } |
| 28 | |
|
| 29 | | impl HelpPage { |
| 30 | | |
| 31 | 2× | pub fn repo_url(&self) -> String { |
| 32 | 2× | format!("{}/{}/REPOSITORY", self.base, self.who) |
| 33 | 2× | } |
| 34 | |
|
| 35 | | |
| 36 | 1× | pub fn agent_home_cmd(&self) -> String { |
| 37 | 1× | format!( |
| 38 | | "export OXY_HOME=~/.oxy-agents/claude\noxy config --user author.signer keyless\noxy config --user keyless.hub {base}\noxy config --user core.sign seal\noxy auth grant {base} # paste the token, then Ctrl-D", |
| 39 | | base = self.base |
| 40 | | ) |
| 41 | 1× | } |
| 42 | |
|
| 43 | | |
| 44 | 1× | pub fn subject_grant_cmd(&self) -> String { |
| 45 | 1× | format!( |
| 46 | | "curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy policy grant-subject agent:claude@{} --issuer hub.identity --scope changes,refs", |
| 47 | | self.base, self.who |
| 48 | | ) |
| 49 | 1× | } |
| 50 | |
|
| 51 | 1× | pub fn delegate_cmd(&self) -> String { |
| 52 | 1× | format!( |
| 53 | | "curl -fsSL {}/.well-known/oxyhub-key -o hub.identity\noxy identity delegate add hub.identity --scope changes,refs", |
| 54 | | self.base |
| 55 | | ) |
| 56 | 1× | } |
| 57 | |
|
| 58 | 1× | pub fn clone_cmd(&self) -> String { |
| 59 | 1× | let url = self.repo_url(); |
| 60 | 1× | match &self.q.ca_url { |
| 61 | 0× | Some(_) => format!("OXY_CA={} oxy clone {url}", self.q.ca_file), |
| 62 | 1× | None => format!("oxy clone {url}"), |
| 63 | | } |
| 64 | 1× | } |
| 65 | | } |