add exit command
This commit is contained in:
@@ -144,6 +144,7 @@ enum SessionInstruction {
|
|||||||
Hint,
|
Hint,
|
||||||
Auto,
|
Auto,
|
||||||
Stock,
|
Stock,
|
||||||
|
Exit,
|
||||||
Klondike(KlondikeInstruction),
|
Klondike(KlondikeInstruction),
|
||||||
}
|
}
|
||||||
impl core::str::FromStr for SessionInstruction {
|
impl core::str::FromStr for SessionInstruction {
|
||||||
@@ -154,6 +155,7 @@ impl core::str::FromStr for SessionInstruction {
|
|||||||
"UNDO" | "undo" | "u" => Self::Undo,
|
"UNDO" | "undo" | "u" => Self::Undo,
|
||||||
"HINT" | "hint" | "h" => Self::Hint,
|
"HINT" | "hint" | "h" => Self::Hint,
|
||||||
"AUTO" | "auto" | "a" => Self::Auto,
|
"AUTO" | "auto" | "a" => Self::Auto,
|
||||||
|
"exit" => Self::Exit,
|
||||||
"s" => Self::Stock,
|
"s" => Self::Stock,
|
||||||
other => {
|
other => {
|
||||||
let Parsed(ki) = other.parse()?;
|
let Parsed(ki) = other.parse()?;
|
||||||
@@ -181,6 +183,7 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
match instruction {
|
match instruction {
|
||||||
SessionInstruction::New => session = Session::new(Klondike::new_random_default()),
|
SessionInstruction::New => session = Session::new(Klondike::new_random_default()),
|
||||||
SessionInstruction::Undo => session.undo(),
|
SessionInstruction::Undo => session.undo(),
|
||||||
|
SessionInstruction::Exit => break Ok(()),
|
||||||
SessionInstruction::Hint => {
|
SessionInstruction::Hint => {
|
||||||
for instruction in session.possible_instructions() {
|
for instruction in session.possible_instructions() {
|
||||||
println!("{instruction:?}");
|
println!("{instruction:?}");
|
||||||
|
|||||||
Reference in New Issue
Block a user