mirror of
https://codeberg.org/icewind/haze.git
synced 2026-06-03 17:14:08 +02:00
add shell command
This commit is contained in:
parent
bf69ed599b
commit
13fde5a378
3 changed files with 55 additions and 1 deletions
10
README.md
10
README.md
|
|
@ -37,7 +37,7 @@ haze start [database] [php-version]
|
||||||
```
|
```
|
||||||
|
|
||||||
Where `database` is one of `sqlite`, `mysql`, `mariadb` or `pgsql` with an optional version (e.g. `pgsql:12`), defaults to `sqlite`.
|
Where `database` is one of `sqlite`, `mysql`, `mariadb` or `pgsql` with an optional version (e.g. `pgsql:12`), defaults to `sqlite`.
|
||||||
And `php-version` is one of `7.2`, `7.3`, `7.4`, `8.0`, `7` or `8`, defaults to `8.0`
|
And `php-version` is one of `7.3`, `7.4`, `8.0`, `7` or `8`, defaults to `8.0`
|
||||||
|
|
||||||
Additionally, you can use the following options when starting an instance:
|
Additionally, you can use the following options when starting an instance:
|
||||||
- `s3`: setup an S3 server and configure to Nextcloud to use it as primary storage
|
- `s3`: setup an S3 server and configure to Nextcloud to use it as primary storage
|
||||||
|
|
@ -98,6 +98,14 @@ haze [match] exec [cmd]
|
||||||
|
|
||||||
If no `cmd` is specified it will launch `bash`
|
If no `cmd` is specified it will launch `bash`
|
||||||
|
|
||||||
|
#### Create a new instance and run a command
|
||||||
|
|
||||||
|
```bash
|
||||||
|
haze [match] shell [cmd]
|
||||||
|
```
|
||||||
|
|
||||||
|
If no `cmd` is specified it will launch `bash`
|
||||||
|
|
||||||
#### Execute an occ command on an instance
|
#### Execute an occ command on an instance
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|
|
||||||
13
src/args.rs
13
src/args.rs
|
|
@ -50,6 +50,10 @@ pub enum HazeArgs {
|
||||||
options: CloudOptions,
|
options: CloudOptions,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
},
|
},
|
||||||
|
Shell {
|
||||||
|
options: CloudOptions,
|
||||||
|
command: Vec<String>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||||
|
|
@ -192,6 +196,12 @@ impl HazeArgs {
|
||||||
.ok_or_else(|| Report::msg("No path provided"))?;
|
.ok_or_else(|| Report::msg("No path provided"))?;
|
||||||
Ok(HazeArgs::Fmt { path })
|
Ok(HazeArgs::Fmt { path })
|
||||||
}
|
}
|
||||||
|
HazeCommand::Shell => {
|
||||||
|
let mut args = args.peekable();
|
||||||
|
let options = CloudOptions::parse(&mut args)?;
|
||||||
|
let command = args.map(S::into).collect();
|
||||||
|
Ok(HazeArgs::Shell { options, command })
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -210,6 +220,7 @@ pub enum HazeCommand {
|
||||||
Open,
|
Open,
|
||||||
Fmt,
|
Fmt,
|
||||||
Integration,
|
Integration,
|
||||||
|
Shell,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl FromStr for HazeCommand {
|
impl FromStr for HazeCommand {
|
||||||
|
|
@ -230,6 +241,7 @@ impl FromStr for HazeCommand {
|
||||||
"fmt" => Ok(HazeCommand::Fmt),
|
"fmt" => Ok(HazeCommand::Fmt),
|
||||||
"format" => Ok(HazeCommand::Fmt),
|
"format" => Ok(HazeCommand::Fmt),
|
||||||
"integration" => Ok(HazeCommand::Integration),
|
"integration" => Ok(HazeCommand::Integration),
|
||||||
|
"shell" => Ok(HazeCommand::Shell),
|
||||||
_ => Err(Report::msg(format!("Unknown command: {}", s))),
|
_ => Err(Report::msg(format!("Unknown command: {}", s))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -250,6 +262,7 @@ impl HazeCommand {
|
||||||
HazeCommand::Open => true,
|
HazeCommand::Open => true,
|
||||||
HazeCommand::Fmt => false,
|
HazeCommand::Fmt => false,
|
||||||
HazeCommand::Integration => false,
|
HazeCommand::Integration => false,
|
||||||
|
HazeCommand::Shell => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
33
src/main.rs
33
src/main.rs
|
|
@ -349,6 +349,39 @@ async fn main() -> Result<()> {
|
||||||
}
|
}
|
||||||
cloud.destroy(&mut docker).await?;
|
cloud.destroy(&mut docker).await?;
|
||||||
}
|
}
|
||||||
|
HazeArgs::Shell { command, options } => {
|
||||||
|
let cloud = Cloud::create(&mut docker, options, &config).await?;
|
||||||
|
println!("Waiting for servers to start");
|
||||||
|
cloud.wait_for_start(&mut docker).await?;
|
||||||
|
println!("Installing");
|
||||||
|
if let Err(e) = cloud
|
||||||
|
.exec(
|
||||||
|
&mut docker,
|
||||||
|
vec![
|
||||||
|
"install",
|
||||||
|
&config.auto_setup.username,
|
||||||
|
&config.auto_setup.password,
|
||||||
|
],
|
||||||
|
false,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
cloud.destroy(&mut docker).await?;
|
||||||
|
return Err(e);
|
||||||
|
}
|
||||||
|
cloud
|
||||||
|
.exec(
|
||||||
|
&mut docker,
|
||||||
|
if command.is_empty() {
|
||||||
|
vec!["bash".to_string()]
|
||||||
|
} else {
|
||||||
|
command
|
||||||
|
},
|
||||||
|
true,
|
||||||
|
)
|
||||||
|
.await?;
|
||||||
|
cloud.destroy(&mut docker).await?;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue