Advance version number and introduce conditional compiled code

This commit is contained in:
Jaby Blubb 2023-08-24 00:06:03 +02:00
parent 1aaf59f036
commit 25e04d8678
3 changed files with 24 additions and 18 deletions

View File

@ -1,6 +1,6 @@
[package]
name = "readmap"
version = "0.1.0"
version = "1.0.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -3,14 +3,16 @@ use tool_helper::{Error, exit_with_error};
use readmap::types::MemoryMap;
use std::{io::{BufRead, BufReader}, path::PathBuf, process::{Child, Command, Stdio}};
pub const RUN_DUMP_TOOL_IN_WSL:bool = cfg!(windows);
#[derive(Parser)]
#[clap(about = "Opens and scans a MAP file to print extended information", long_about = None)]
#[clap(about = "Opens and scans an ELF file to print extended information", long_about = None)]
struct CommandLine {
#[clap(value_parser, help="Input MAP file for scannning")]
#[clap(value_parser, help="Input ELF file for scannning")]
input: PathBuf,
#[clap(long="wsl", default_value_t=false)]
#[clap(long="wsl", help="Run \"objdump\" in WSL", default_value_t=RUN_DUMP_TOOL_IN_WSL)]
use_wsl: bool,
#[clap(short='o')]
#[clap(short='o', help="Output a memory map file with running the tool")]
output: Option<PathBuf>
}

View File

@ -1,18 +1,20 @@
use clap::Parser;
use crossterm::{event::{self, Event as CEvent, KeyboardEnhancementFlags, KeyEventKind, PushKeyboardEnhancementFlags}, execute, terminal};
use psxreadmap::{ConsoleUI, Event, EventReceiver, Terminal, load_memory_map, UIState};
use std::{io, path::PathBuf, sync::mpsc, thread, time::{Duration, Instant}};
use std::{io::{self, Stdout}, path::PathBuf, sync::mpsc, thread, time::{Duration, Instant}};
use tool_helper::{Error, exit_with_error};
use ratatui::backend::CrosstermBackend;
pub const RUN_DUMP_TOOL_IN_WSL:bool = cfg!(windows);
#[derive(Parser)]
#[clap(about = "Opens and scans a MAP file to print extended information", long_about = None)]
#[clap(about = "Opens and scans an ELF file to print extended memory information", long_about = None)]
struct CommandLine {
#[clap(value_parser, help="Input MAP file for scannning")]
#[clap(value_parser, help="Input ELF file for scannning")]
input: PathBuf,
#[clap(long="wsl", default_value_t=false)]
#[clap(long="wsl", help="Run \"objdump\" in WSL", default_value_t=RUN_DUMP_TOOL_IN_WSL)]
use_wsl: bool,
#[clap(short='o')]
#[clap(short='o', help="Output a memory map file with running the tool")]
output: Option<PathBuf>
}
@ -25,7 +27,7 @@ pub fn main() {
}
},
Err(error) => {
println!("{}", error)
println!("{})", error)
}
}
}
@ -88,16 +90,18 @@ fn start_event_loop() -> EventReceiver {
}
fn setup_console() -> Result<Terminal, Error> {
fn open_stdout() -> Result<Stdout, Error> {
let mut stdout = io::stdout();
if cfg!(unix) {
execute!(stdout, PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::REPORT_EVENT_TYPES))?;
}
Ok(stdout)
}
terminal::enable_raw_mode()?;
// Setup Crossterm for the Terminal
let stdout = {
let mut stdout = io::stdout();
if let Err(_) = execute!(stdout, PushKeyboardEnhancementFlags(KeyboardEnhancementFlags::REPORT_EVENT_TYPES)) {
// This fails under Windows but is required for Linux
}
stdout
};
let stdout = open_stdout()?;
let backend = CrosstermBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;