refactor: give every command we run a type of its own
This commit is contained in:
44
src/cmd/django.rs
Normal file
44
src/cmd/django.rs
Normal 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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user