Skip to content

Commit b1d6e8e

Browse files
Timna BrownTimna Brown
authored andcommitted
Fix clippy issues and normalize formatting
1 parent baebe20 commit b1d6e8e

5 files changed

Lines changed: 88 additions & 51 deletions

File tree

src/auth/mod.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,12 @@ pub fn remove_token(provider: &str) -> Result<()> {
8787

8888
pub fn load_github_identity() -> Result<Option<GitHubIdentity>> {
8989
let store = load_store()?;
90-
Ok(store
91-
.github_identity
92-
.or_else(|| store.tokens.get("github").and_then(|token| token.github_identity.clone())))
90+
Ok(store.github_identity.or_else(|| {
91+
store
92+
.tokens
93+
.get("github")
94+
.and_then(|token| token.github_identity.clone())
95+
}))
9396
}
9497

9598
pub fn save_github_identity(identity: GitHubIdentity) -> Result<()> {

src/cli/init.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,7 @@ fn non_empty_lines(s: &str) -> Vec<String> {
583583
fn last_url_segment(url: &str) -> Result<String> {
584584
url.trim_end_matches('/')
585585
.split('/')
586-
.last()
586+
.next_back()
587587
.filter(|s| !s.is_empty())
588588
.map(|s| s.to_string())
589589
.context("could not extract name from URL")

src/cli/login.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/// Browser-based login by delegating to each platform's own CLI tool.
22
///
33
/// - GitHub -> `gh auth login --web --hostname github.com`
4-
/// then reads the token via `gh auth token`
4+
/// then reads the token via `gh auth token`
55
/// - Azure DevOps -> `az login --allow-no-subscriptions`
6-
/// then reads the token via `az account get-access-token`
6+
/// then reads the token via `az account get-access-token`
77
/// - GitLab -> `glab auth login`
8-
/// then reads the token via `glab auth token`
8+
/// then reads the token via `glab auth token`
99
///
1010
/// No OAuth app registration required. Each platform CLI owns the browser
1111
/// redirect; devopster just reads the resulting token and caches it so the

src/cli/mod.rs

Lines changed: 78 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,19 @@ async fn run_interactive_launcher(config_path: &str) -> Result<()> {
106106
ui::note("Direct commands still work any time, for example: devopster repo audit");
107107

108108
let options = vec![
109-
menu_item("Set up configuration", "Create or refresh devopster-config.yaml"),
109+
menu_item(
110+
"Set up configuration",
111+
"Create or refresh devopster-config.yaml",
112+
),
110113
menu_item("Sign in", "Connect GitHub, Azure DevOps, or GitLab"),
111-
menu_item("Manage repositories", "List, audit, fix, blueprint, or sync"),
112-
menu_item("Generate catalog", "Export catalog.json for your organization"),
114+
menu_item(
115+
"Manage repositories",
116+
"List, audit, fix, blueprint, or sync",
117+
),
118+
menu_item(
119+
"Generate catalog",
120+
"Export catalog.json for your organization",
121+
),
113122
menu_item("Align topics", "Apply missing template topics"),
114123
menu_item("View statistics", "Check metadata coverage and compliance"),
115124
menu_item("Show help", "See the direct CLI command reference"),
@@ -120,20 +129,26 @@ async fn run_interactive_launcher(config_path: &str) -> Result<()> {
120129
0 => launch_init(config_path).await?,
121130
1 => launch_login().await?,
122131
2 => launch_repo(config_path).await?,
123-
3 => run_command(
124-
Commands::Catalog(catalog::CatalogCommand {
125-
action: catalog::CatalogAction::Generate(catalog::GenerateCatalogCommand {}),
126-
}),
127-
config_path,
128-
)
129-
.await?,
130-
4 => run_command(
131-
Commands::Topics(topics::TopicsCommand {
132-
action: topics::TopicsAction::Align(topics::AlignTopicsCommand {}),
133-
}),
134-
config_path,
135-
)
136-
.await?,
132+
3 => {
133+
run_command(
134+
Commands::Catalog(catalog::CatalogCommand {
135+
action: catalog::CatalogAction::Generate(
136+
catalog::GenerateCatalogCommand {},
137+
),
138+
}),
139+
config_path,
140+
)
141+
.await?
142+
}
143+
4 => {
144+
run_command(
145+
Commands::Topics(topics::TopicsCommand {
146+
action: topics::TopicsAction::Align(topics::AlignTopicsCommand {}),
147+
}),
148+
config_path,
149+
)
150+
.await?
151+
}
137152
5 => launch_stats(config_path).await?,
138153
6 => print_help()?,
139154
_ => break,
@@ -156,22 +171,26 @@ async fn launch_init(config_path: &str) -> Result<()> {
156171
menu_item("Back", "Return to the main launcher"),
157172
];
158173
match ui::select("Init", &options, 0)? {
159-
0 => run_command(
160-
Commands::Init(init::InitCommand {
161-
output: config_path.to_string(),
162-
no_login: false,
163-
}),
164-
config_path,
165-
)
166-
.await,
167-
1 => run_command(
168-
Commands::Init(init::InitCommand {
169-
output: config_path.to_string(),
170-
no_login: true,
171-
}),
172-
config_path,
173-
)
174-
.await,
174+
0 => {
175+
run_command(
176+
Commands::Init(init::InitCommand {
177+
output: config_path.to_string(),
178+
no_login: false,
179+
}),
180+
config_path,
181+
)
182+
.await
183+
}
184+
1 => {
185+
run_command(
186+
Commands::Init(init::InitCommand {
187+
output: config_path.to_string(),
188+
no_login: true,
189+
}),
190+
config_path,
191+
)
192+
.await
193+
}
175194
_ => Ok(()),
176195
}
177196
}
@@ -184,7 +203,10 @@ async fn launch_login() -> Result<()> {
184203
menu_item("Azure DevOps", "Sign in with the az CLI"),
185204
menu_item("GitLab", "Sign in with the glab CLI"),
186205
menu_item("All providers", "Run all sign-in flows one after another"),
187-
menu_item("Login status", "Check whether providers are already signed in"),
206+
menu_item(
207+
"Login status",
208+
"Check whether providers are already signed in",
209+
),
188210
menu_item("Logout", "Remove saved credentials for one provider"),
189211
menu_item("Back", "Return to the main launcher"),
190212
];
@@ -237,11 +259,23 @@ async fn launch_repo(config_path: &str) -> Result<()> {
237259
ui::section("Repository actions");
238260
ui::note("Pick the task you want to perform across repositories.");
239261
let options = vec![
240-
menu_item("List repositories", "Browse repositories, optionally by topic"),
241-
menu_item("Audit repositories", "Find missing metadata or branch drift"),
262+
menu_item(
263+
"List repositories",
264+
"Browse repositories, optionally by topic",
265+
),
266+
menu_item(
267+
"Audit repositories",
268+
"Find missing metadata or branch drift",
269+
),
242270
menu_item("Fix repositories", "Interactively repair missing metadata"),
243-
menu_item("Create from blueprint", "Provision a new repository from a template"),
244-
menu_item("Sync shared files", "Push local or blueprint content to repositories"),
271+
menu_item(
272+
"Create from blueprint",
273+
"Provision a new repository from a template",
274+
),
275+
menu_item(
276+
"Sync shared files",
277+
"Push local or blueprint content to repositories",
278+
),
245279
menu_item("Back", "Return to the main launcher"),
246280
];
247281

@@ -286,7 +320,10 @@ async fn launch_repo(config_path: &str) -> Result<()> {
286320
4 => {
287321
let sync_options = vec![
288322
menu_item("Sync local files", "Use a local folder such as .github"),
289-
menu_item("Sync from blueprint", "Compare against the configured blueprint repo"),
323+
menu_item(
324+
"Sync from blueprint",
325+
"Compare against the configured blueprint repo",
326+
),
290327
];
291328
let sync_choice = ui::select("Sync mode", &sync_options, 0)?;
292329
let from_blueprint = sync_choice == 1;
@@ -329,10 +366,8 @@ async fn launch_repo(config_path: &str) -> Result<()> {
329366
async fn launch_stats(config_path: &str) -> Result<()> {
330367
ui::section("Statistics");
331368
ui::note("View overall metadata health for the configured organization.");
332-
let scope_missing = ui::prompt_confirm(
333-
"Write non-compliant repositories into scoped_repos?",
334-
false,
335-
)?;
369+
let scope_missing =
370+
ui::prompt_confirm("Write non-compliant repositories into scoped_repos?", false)?;
336371
run_command(
337372
Commands::Stats(stats::StatsCommand { scope_missing }),
338373
config_path,

src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
mod ai;
21
mod auth;
32
mod cli;
43
mod config;

0 commit comments

Comments
 (0)