mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-05-26 20:49:55 +00:00
chore: Clippy fixes
This commit is contained in:
@@ -38,26 +38,23 @@ struct Subcommand {
|
|||||||
|
|
||||||
|
|
||||||
fn flatten_subcommands(command: &Command) -> Vec<Subcommand> {
|
fn flatten_subcommands(command: &Command) -> Vec<Subcommand> {
|
||||||
let mut subcommands = Vec::new();
|
|
||||||
let mut name_stack = Vec::new();
|
|
||||||
|
|
||||||
fn flatten(
|
fn flatten(
|
||||||
subcommands: &mut Vec<Subcommand>,
|
subcommands: &mut Vec<Subcommand>,
|
||||||
stack: &mut Vec<String>,
|
name_stack: &mut Vec<String>,
|
||||||
command: &Command
|
command: &Command
|
||||||
) {
|
) {
|
||||||
let depth = stack.len();
|
let depth = name_stack.len();
|
||||||
stack.push(command.get_name().to_owned());
|
name_stack.push(command.get_name().to_owned());
|
||||||
|
|
||||||
// do not include the root command
|
// do not include the root command
|
||||||
if depth > 0 {
|
if depth > 0 {
|
||||||
let name = stack.join(" ");
|
let name = name_stack.join(" ");
|
||||||
|
|
||||||
let description = command
|
let description = command
|
||||||
.get_long_about()
|
.get_long_about()
|
||||||
.or_else(|| command.get_about())
|
.or_else(|| command.get_about())
|
||||||
.map(|about| about.to_string())
|
.map_or_else(|| "_(no description)_".to_owned(), ToString::to_string);
|
||||||
.unwrap_or("_(no description)_".to_owned());
|
|
||||||
|
|
||||||
subcommands.push(
|
subcommands.push(
|
||||||
Subcommand {
|
Subcommand {
|
||||||
@@ -69,12 +66,15 @@ fn flatten_subcommands(command: &Command) -> Vec<Subcommand> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for command in command.get_subcommands() {
|
for command in command.get_subcommands() {
|
||||||
flatten(subcommands, stack, command);
|
flatten(subcommands, name_stack, command);
|
||||||
}
|
}
|
||||||
|
|
||||||
stack.pop();
|
name_stack.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut subcommands = Vec::new();
|
||||||
|
let mut name_stack = Vec::new();
|
||||||
|
|
||||||
flatten(&mut subcommands, &mut name_stack, command);
|
flatten(&mut subcommands, &mut name_stack, command);
|
||||||
|
|
||||||
subcommands
|
subcommands
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ struct FileQueue {
|
|||||||
|
|
||||||
impl FileQueue {
|
impl FileQueue {
|
||||||
fn write(self, root: &Path, dry_run: bool) -> std::io::Result<()> {
|
fn write(self, root: &Path, dry_run: bool) -> std::io::Result<()> {
|
||||||
for (path, contents) in self.queue.into_iter() {
|
for (path, contents) in self.queue {
|
||||||
let path = root.join(&path);
|
let path = root.join(&path);
|
||||||
|
|
||||||
eprintln!("Writing {}", path.display());
|
eprintln!("Writing {}", path.display());
|
||||||
@@ -35,9 +35,7 @@ impl FileOutput for FileQueue {
|
|||||||
assert!(path.is_relative(), "path must be relative");
|
assert!(path.is_relative(), "path must be relative");
|
||||||
assert!(path.extension().is_some(), "path must not point to a directory");
|
assert!(path.extension().is_some(), "path must not point to a directory");
|
||||||
|
|
||||||
if self.queue.contains_key(&path) {
|
assert!(!self.queue.contains_key(&path), "attempted to create an already created file {}", path.display());
|
||||||
panic!("attempted to create an already created file {}", path.display());
|
|
||||||
}
|
|
||||||
|
|
||||||
self.queue.insert(path, contents);
|
self.queue.insert(path, contents);
|
||||||
}
|
}
|
||||||
@@ -49,6 +47,7 @@ pub(crate) struct Args {
|
|||||||
root: Option<PathBuf>,
|
root: Option<PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[expect(clippy::needless_pass_by_value)]
|
||||||
pub(super) fn run(common_args: crate::Args, task_args: Args) -> TaskResult<()> {
|
pub(super) fn run(common_args: crate::Args, task_args: Args) -> TaskResult<()> {
|
||||||
let mut queue = FileQueue::default();
|
let mut queue = FileQueue::default();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user