Skip to content

Commit

Permalink
format: cb455b5
Browse files Browse the repository at this point in the history
  • Loading branch information
higuruchi committed Mar 19, 2022
1 parent cb455b5 commit 2d3d758
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 15 deletions.
11 changes: 6 additions & 5 deletions src/cmd/launch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,10 @@ where
// execでプログラムを実行

let main = CString::new(launch.cmd().main())?;
let mut detail: Vec<CString> = vec!(main.clone());
let mut detail: Vec<CString> = vec![main.clone()];
for d in launch.cmd().detail() {
let d_clone = d.clone();
detail.push(CString::new(d_clone)?);

}
execv(&main, &detail)?;
}
Expand Down Expand Up @@ -178,9 +177,11 @@ fn remount<DO: Downloader>(launch: &command::Launch<DO>) -> Result<(), Box<dyn s
let rootfs_path = match launch.rootfs_option() {
RootFSOption::RootfsImage(image) => {
match image.check_rootfs_newest() {
Ok(is_newest) => if !is_newest {
image.download_image()?;
},
Ok(is_newest) => {
if !is_newest {
image.download_image()?;
}
}
Err(e) => {
Err(e)?;
}
Expand Down
5 changes: 2 additions & 3 deletions src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ impl Command {
index: 0,
main: main,
detail: detail,

}
}

Expand All @@ -384,9 +383,9 @@ impl Command {
// if self.index <= self.detail.len() {
// return None
// }

// let index = self.index;
// self.index += 1;
// Some(&self.detail[index])
// }
// }
// }
20 changes: 13 additions & 7 deletions src/parser.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use crate::command::{
self, Delete, Error, Exec, File, FileSubCommand, Init, Launch, List, RootFSOption, SubCommand, Command,
self, Command, Delete, Error, Exec, File, FileSubCommand, Init, Launch, List, RootFSOption,
SubCommand,
};
use crate::{container, image, image_downloader, image_downloader_lxd, user};
use clap::{Args, Parser, Subcommand};
use regex::Regex;
use std::path::PathBuf;

pub fn parse<'a>() -> Result<SubCommand<impl image_downloader::Downloader>, Box<dyn std::error::Error>>
{
pub fn parse<'a>(
) -> Result<SubCommand<impl image_downloader::Downloader>, Box<dyn std::error::Error>> {
let args: Cli = Cli::parse();
match args.action {
Action::Delete(delete) => Ok(SubCommand::Delete(initialize_delete(delete)?)),
Expand Down Expand Up @@ -69,7 +70,12 @@ fn initialize_launch<'a>(
)?;

let container = container::Container::new(&launch.container_id_or_name)?;
Ok(Launch::new(container, rootfs, String::from(launch.name), Command::new(launch.cmd))?)
Ok(Launch::new(
container,
rootfs,
String::from(launch.name),
Command::new(launch.cmd),
)?)
}

fn initialize_list() -> Result<List, Box<dyn std::error::Error>> {
Expand All @@ -95,12 +101,12 @@ fn check_rootfs(
let user = user::User::new()?;

// distribution/version format validation
// e.g. busybox/1.34.1
// e.g. busybox/1.34.1
let distri_and_version = match arg_rootfs_image.split_once("/") {
Some(d) => d,
None => Err(crate::image::Error::ImageSyntaxError)?
None => Err(crate::image::Error::ImageSyntaxError)?,
};
// .unwrap_or(Err(crate::image::Error::ImageSyntaxError)?);
// .unwrap_or(Err(crate::image::Error::ImageSyntaxError)?);

if distri_and_version.0.len() == 0 || distri_and_version.1.len() == 0 {
Err(crate::image::Error::ImageSyntaxError)?
Expand Down

0 comments on commit 2d3d758

Please sign in to comment.