Skip to content

Commit

Permalink
Move commands to a module
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Hrica <[email protected]>
  • Loading branch information
mtjhrc committed Oct 25, 2023
1 parent b0ac8f0 commit 8bfe055
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 17 deletions.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions src/create.rs → src/commands/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ use std::io::Write;
use std::path::Path;
use std::process::Command;

use super::utils::{get_buildah_args, mount_container, umount_container, BuildahCommand};
use crate::utils::{path_pairs_to_hash_map, port_pairs_to_hash_map, PathPair, PortPair};
use crate::utils::{
get_buildah_args, mount_container, path_pairs_to_hash_map, port_pairs_to_hash_map,
umount_container, BuildahCommand, PathPair, PortPair,
};
use crate::{KrunvmConfig, VmConfig, APP_NAME};

#[cfg(target_os = "macos")]
Expand Down
2 changes: 1 addition & 1 deletion src/delete.rs → src/commands/delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{KrunvmConfig, APP_NAME};
use clap::Args;

use super::utils::{remove_container, umount_container};
use crate::utils::{remove_container, umount_container};

/// Delete an existing microVM
#[derive(Args, Debug)]
Expand Down
File renamed without changes.
13 changes: 13 additions & 0 deletions src/commands/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
mod changevm;
mod config;
mod create;
mod delete;
mod list;
mod start;

pub use changevm::ChangeVmCmd;
pub use config::ConfigCmd;
pub use create::CreateCmd;
pub use delete::DeleteCmd;
pub use list::ListCmd;
pub use start::StartCmd;
4 changes: 2 additions & 2 deletions src/start.rs → src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use std::os::unix::io::AsRawFd;
#[cfg(target_os = "macos")]
use std::path::Path;

use super::bindings;
use super::utils::{mount_container, umount_container};
use crate::bindings;
use crate::utils::{mount_container, umount_container};
use crate::{KrunvmConfig, VmConfig};

#[derive(Args, Debug)]
Expand Down
15 changes: 3 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,16 @@ use std::fs::File;
#[cfg(target_os = "macos")]
use std::io::{self, Read, Write};

use crate::changevm::ChangeVmCmd;
use crate::config::ConfigCmd;
use crate::create::CreateCmd;
use crate::delete::DeleteCmd;
use crate::list::ListCmd;
use crate::start::StartCmd;
use clap::{Parser, Subcommand};
use serde_derive::{Deserialize, Serialize};
#[cfg(target_os = "macos")]
use text_io::read;
use crate::commands::{ChangeVmCmd, ConfigCmd, CreateCmd, DeleteCmd, ListCmd, StartCmd};

#[allow(unused)]
mod bindings;
mod changevm;
mod config;
mod create;
mod delete;
mod list;
mod start;
mod utils;
mod commands;

const APP_NAME: &str = "krunvm";

Expand Down

0 comments on commit 8bfe055

Please sign in to comment.