refactor: give every command we run a type of its own

This commit is contained in:
2026-09-08 11:54:21 +00:00
parent 3d06f7dcb0
commit d7626d9f5e
16 changed files with 968 additions and 324 deletions

44
src/cmd/django.rs Normal file
View File

@@ -0,0 +1,44 @@
use super::{Argv, Cmd};
// an interactive shell in the django container
pub struct Bash;
impl Cmd for Bash {
fn argv(&self) -> Argv {
Argv::new("bash")
}
}
// django's manage.py, with the subcommand and its arguments
pub struct Manage<'a> {
args: &'a [String],
}
impl<'a> Manage<'a> {
pub fn new(args: &'a [String]) -> Self {
Self { args }
}
}
impl Cmd for Manage<'_> {
fn argv(&self) -> Argv {
Argv::new("python").arg("manage.py").args(self.args)
}
}
// whatever the caller typed, passed through as it stands
pub struct Words<'a> {
words: &'a [String],
}
impl<'a> Words<'a> {
pub fn new(words: &'a [String]) -> Self {
Self { words }
}
}
impl Cmd for Words<'_> {
fn argv(&self) -> Argv {
Argv::default().args(self.words)
}
}