Compare commits

..

No commits in common. "246124d4d19ce814f849a943cac4ed630ad87f8d" and "72fd5ec46f1e930140e7801d462129d5cb045217" have entirely different histories.

5 changed files with 6 additions and 40 deletions

View File

@ -25,9 +25,6 @@ pub enum Repo {
}
/// check if yaml line matches and returns the split of repo string and rest
/// the first &str is the image tag
/// it will be used to not change the identation
/// the second &str will the the identifier for the image
pub fn match_yaml_image(input: &str) -> Result<(&str, &str), Error> {
lazy_static::lazy_static! {
static ref REGEX: Regex = Regex::new(r"^( +image *: *)([a-z0-9\./:]+)").unwrap();
@ -40,7 +37,6 @@ pub fn match_yaml_image(input: &str) -> Result<(&str, &str), Error> {
Ok((caps.get(1).unwrap().as_str(), caps.get(2).unwrap().as_str()))
}
/// takes the identifier and splits off the tag it exists
pub fn split_tag_from_repo(input: &str) -> Result<(&str, &str), Error> {
lazy_static::lazy_static! {
static ref REGEX: Regex = Regex::new(r"^([a-z0-9\./[^:]]*):?([a-z0-9._\-]*)").unwrap();
@ -63,7 +59,6 @@ pub fn split_tag_from_repo(input: &str) -> Result<(&str, &str), Error> {
Ok((front, back))
}
/// takes an identifier and changes it to a Repo enum
pub fn split_repo_without_tag(repo: &str) -> Result<Repo, Error> {
let repo = repo.trim();
let split_repo: Vec<&str> = repo.split('/').collect();

View File

@ -28,16 +28,6 @@ pub enum State {
SelectService,
}
impl std::fmt::Display for State {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
State::EditRepo => write!(f, "Edit repository"),
State::SelectTag => write!(f, "Select a tag"),
State::SelectService => write!(f, "Select a image"),
}
}
}
impl std::iter::Iterator for State {
type Item = Self;
@ -113,14 +103,13 @@ impl Ui {
Ok(Key::Ctrl('q')) => break 'core, //quit program without saving
Ok(Key::Char('\t')) => {
ui.state.next();
ui.info.set_info(&ui.state);
}
Ok(Key::Ctrl('s')) => match ui.services.save() {
Err(e) => {
ui.info.set_info(&format!("{}", e));
continue;
}
Ok(_) => ui.info.set_text("Saved compose file"),
Ok(_) => ui.info.set_info("Saved compose file"),
},
Ok(Key::Ctrl('r')) => {
ui.repo.confirm();
@ -150,7 +139,7 @@ impl Ui {
Ok(Key::Char(key)) => match ui.state {
State::SelectService => (),
State::EditRepo => {
ui.info.set_text("Editing Repository");
ui.info.set_info("Editing Repository");
ui.repo.handle_input(Key::Char(key));
}
State::SelectTag => (),
@ -158,7 +147,7 @@ impl Ui {
Ok(Key::Backspace) => match ui.state {
State::SelectService => (),
State::EditRepo => {
ui.info.set_text("Editing Repository");
ui.info.set_info("Editing Repository");
ui.repo.handle_input(Key::Backspace);
}
State::SelectTag => (),

View File

@ -17,15 +17,6 @@ pub enum State {
SelectTag,
}
impl std::fmt::Display for State {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
State::EditRepo => write!(f, "Edit repository"),
State::SelectTag => write!(f, "Select a tag"),
}
}
}
impl std::iter::Iterator for State {
type Item = Self;
@ -106,7 +97,6 @@ impl NoYaml {
Ok(Key::Ctrl('q')) => break 'core,
Ok(Key::Char('\t')) => {
ui.state.next();
ui.info.set_info(&ui.state);
}
Ok(Key::Ctrl('r')) => {
ui.repo.confirm();
@ -121,7 +111,7 @@ impl NoYaml {
},
Ok(Key::Char(key)) => match ui.state {
State::EditRepo => {
ui.info.set_text("Editing Repository");
ui.info.set_info("Editing Repository");
ui.repo.handle_input(Key::Char(key));
}
State::SelectTag => {
@ -130,7 +120,7 @@ impl NoYaml {
},
Ok(Key::Backspace) => match ui.state {
State::EditRepo => {
ui.info.set_text("Editing Repository");
ui.info.set_info("Editing Repository");
ui.repo.handle_input(Key::Backspace);
}
State::SelectTag => (),

View File

@ -27,13 +27,7 @@ impl Info {
.highlight_style(Style::default().bg(Color::Black))
}
/// set a text to display
pub fn set_text(&mut self, info: &str) {
pub fn set_info(&mut self, info: &str) {
self.info = String::from(info);
}
/// print a text to display
pub fn set_info(&mut self, text: &dyn std::fmt::Display) {
self.info = format!("{}", text);
}
}

View File

@ -34,7 +34,6 @@ pub struct ServiceSwitcher {
impl ServiceSwitcher {
pub fn new(file: &Option<PathBuf>) -> Option<Self> {
//gather possible filenames
let mut file_list = vec![
PathBuf::from("docker-compose.yml"),
PathBuf::from("docker-compose.yaml"),
@ -44,7 +43,6 @@ impl ServiceSwitcher {
Some(file) => file_list.insert(0, file.clone()),
}
//try filenames
for file in file_list {
let list = match File::open(&file) {
Err(_) => continue,