mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-01-10 05:58:03 -05:00
wip: vstc console
This commit is contained in:
@@ -12,3 +12,4 @@ storage = { path = "../storage" }
|
||||
url = "2.2.1"
|
||||
serde = "1.0"
|
||||
serde_qs = "0.8.0"
|
||||
termion = "2.0.1"
|
||||
|
||||
30
vstc/src/console_command.rs
Normal file
30
vstc/src/console_command.rs
Normal file
@@ -0,0 +1,30 @@
|
||||
// use storage::{SledBackend, Storage};
|
||||
|
||||
pub fn console_command(args: &[String]) {
|
||||
// let mut storage = Storage::new(SledBackend::open("./state.vsdb").unwrap());
|
||||
|
||||
match args.get(0).map(String::as_str) {
|
||||
Some("help") => show_help(),
|
||||
Some("new") => todo!(),
|
||||
Some("start") => todo!(),
|
||||
_ => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn show_help() {
|
||||
println!("vstc console");
|
||||
println!();
|
||||
println!("ValueScript console applications");
|
||||
println!();
|
||||
println!("USAGE:");
|
||||
println!(" vstc console [COMMAND] [ARGS]");
|
||||
println!();
|
||||
println!("Commands:");
|
||||
println!(" help, -h, --help Show this message");
|
||||
println!(" new [CLASS_FILE] [ARGS] Create a new console app");
|
||||
println!(" start [APP_FILE] [ARGS] Start an existing console app");
|
||||
println!();
|
||||
println!("Examples:");
|
||||
println!(" vstc console new Tetris.ts Create a tetris game");
|
||||
println!(" vstc console start tetris.vsdb Start tetris");
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
mod assemble_command;
|
||||
mod compile_command;
|
||||
mod console_command;
|
||||
mod db_command;
|
||||
mod handle_diagnostics_cli;
|
||||
mod parse_command_line;
|
||||
mod resolve_entry_path;
|
||||
mod run_command;
|
||||
mod termion_test;
|
||||
mod test_inputs;
|
||||
mod to_bytecode;
|
||||
|
||||
@@ -13,8 +15,10 @@ use std::process::exit;
|
||||
|
||||
use assemble_command::assemble_command;
|
||||
use compile_command::compile_command;
|
||||
use console_command::console_command;
|
||||
use db_command::db_command;
|
||||
use run_command::run_command;
|
||||
use termion_test::termion_test;
|
||||
|
||||
fn main() {
|
||||
let args: Vec<String> = env::args().collect();
|
||||
@@ -25,6 +29,8 @@ fn main() {
|
||||
Some("run") => run_command(&args),
|
||||
Some("compile") => compile_command(&args),
|
||||
Some("db") => db_command(&args),
|
||||
Some("termion") => termion_test(),
|
||||
Some("console") => console_command(&args),
|
||||
_ => {
|
||||
println!("ERROR: Unrecognized command\n");
|
||||
show_help();
|
||||
|
||||
32
vstc/src/termion_test.rs
Normal file
32
vstc/src/termion_test.rs
Normal file
@@ -0,0 +1,32 @@
|
||||
use std::io::{stdin, stdout, Write};
|
||||
use termion::event::{Event, Key, MouseEvent};
|
||||
use termion::input::{MouseTerminal, TermRead};
|
||||
use termion::raw::IntoRawMode;
|
||||
|
||||
pub fn termion_test() {
|
||||
let stdin = stdin();
|
||||
let mut stdout = MouseTerminal::from(stdout().into_raw_mode().unwrap());
|
||||
|
||||
write!(
|
||||
stdout,
|
||||
"{}{}q to exit. Click, click, click!",
|
||||
termion::clear::All,
|
||||
termion::cursor::Goto(1, 1)
|
||||
)
|
||||
.unwrap();
|
||||
stdout.flush().unwrap();
|
||||
|
||||
for c in stdin.events() {
|
||||
let evt = c.unwrap();
|
||||
match evt {
|
||||
Event::Key(Key::Char('q')) => break,
|
||||
Event::Mouse(me) => {
|
||||
if let MouseEvent::Press(_, x, y) = me {
|
||||
write!(stdout, "{}x", termion::cursor::Goto(x, y)).unwrap();
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
stdout.flush().unwrap();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user