starting to get finished
This commit is contained in:
parent
4df9d3e7ff
commit
7b1501f4d8
19
src/ui.rs
19
src/ui.rs
@ -83,19 +83,20 @@ impl Ui {
|
|||||||
match receiver.try_recv() {
|
match receiver.try_recv() {
|
||||||
Ok(Key::Ctrl('q')) => break 'core, //quit program without saving
|
Ok(Key::Ctrl('q')) => break 'core, //quit program without saving
|
||||||
Ok(Key::Char('\t')) => ui.state = ui.state.next(),
|
Ok(Key::Char('\t')) => ui.state = ui.state.next(),
|
||||||
Ok(Key::Ctrl('s')) => {
|
Ok(Key::Ctrl('s')) => match ui.services.save() {
|
||||||
match ui.services.save() {
|
Err(_) => continue,
|
||||||
Err(_) => (), //TODO proper error handling
|
|
||||||
Ok(_) => (),
|
Ok(_) => (),
|
||||||
}
|
},
|
||||||
}
|
|
||||||
Ok(Key::Char('\n')) => match ui.state {
|
Ok(Key::Char('\n')) => match ui.state {
|
||||||
State::EditRepo => {
|
State::EditRepo => {
|
||||||
ui.repo.confirm();
|
ui.repo.confirm();
|
||||||
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
||||||
}
|
}
|
||||||
State::SelectTag => {
|
State::SelectTag => {
|
||||||
let mut repo = ui.services.extract_repo().unwrap();
|
let mut repo = match ui.services.extract_repo() {
|
||||||
|
Err(_) => continue,
|
||||||
|
Ok(s) => s,
|
||||||
|
};
|
||||||
let tag = match ui.tags.get_selected() {
|
let tag = match ui.tags.get_selected() {
|
||||||
Err(_) => continue,
|
Err(_) => continue,
|
||||||
Ok(tag) => tag,
|
Ok(tag) => tag,
|
||||||
@ -123,7 +124,7 @@ impl Ui {
|
|||||||
Ok(Key::Up) => {
|
Ok(Key::Up) => {
|
||||||
if ui.state == State::SelectService && ui.services.find_previous_match() {
|
if ui.state == State::SelectService && ui.services.find_previous_match() {
|
||||||
match ui.services.extract_repo() {
|
match ui.services.extract_repo() {
|
||||||
Err(_) => ui.tags = tag_list::TagList::with_status("no image found"),
|
Err(_) => ui.tags = tag_list::TagList::with_status("No image found"),
|
||||||
Ok(s) => ui.repo.set(s),
|
Ok(s) => ui.repo.set(s),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -133,7 +134,7 @@ impl Ui {
|
|||||||
Ok(Key::Down) => match ui.state {
|
Ok(Key::Down) => match ui.state {
|
||||||
State::SelectService if ui.services.find_next_match() => {
|
State::SelectService if ui.services.find_next_match() => {
|
||||||
match ui.services.extract_repo() {
|
match ui.services.extract_repo() {
|
||||||
Err(_) => ui.tags = tag_list::TagList::with_status("no image found"),
|
Err(_) => ui.tags = tag_list::TagList::with_status("No image found"),
|
||||||
Ok(s) => {
|
Ok(s) => {
|
||||||
ui.repo.set(s);
|
ui.repo.set(s);
|
||||||
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
ui.tags = tag_list::TagList::with_repo(ui.repo.get());
|
||||||
@ -155,6 +156,8 @@ impl Ui {
|
|||||||
//sleep for 32ms (30 fps)
|
//sleep for 32ms (30 fps)
|
||||||
thread::sleep(std::time::Duration::from_millis(32));
|
thread::sleep(std::time::Duration::from_millis(32));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
terminal.clear().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn spawn_stdin_channel(&self) -> mpsc::Receiver<termion::event::Key> {
|
pub fn spawn_stdin_channel(&self) -> mpsc::Receiver<termion::event::Key> {
|
||||||
|
@ -169,7 +169,7 @@ impl ServiceSwitcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn save(&mut self) -> Result<(), std::io::Error> {
|
pub fn save(&mut self) -> Result<(), std::io::Error> {
|
||||||
let name = "docker-compose.yml2";
|
let name = "docker-compose.yml";
|
||||||
let mut file = File::create(name)?;
|
let mut file = File::create(name)?;
|
||||||
for line in &self.list {
|
for line in &self.list {
|
||||||
file.write_all(line.as_bytes())?;
|
file.write_all(line.as_bytes())?;
|
||||||
|
Loading…
Reference in New Issue
Block a user