Add version and help command line arguments (#443)

* add maximized command line argument

* fix println when in release mode on windows
macos-click-through
Keith Simmons 4 years ago committed by GitHub
parent 5b29700513
commit 546937501b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,7 +4,7 @@ use nvim_rs::Neovim;
use tokio::process::ChildStdin;
#[cfg(windows)]
use crate::settings::windows_registry::{
use crate::windows_utils::{
register_rightclick_directory, register_rightclick_file, unregister_rightclick,
};

@ -10,6 +10,7 @@ mod redraw_scheduler;
mod renderer;
mod settings;
mod window;
pub mod windows_utils;
#[macro_use]
extern crate derive_new;
@ -18,10 +19,7 @@ extern crate rust_embed;
#[macro_use]
extern crate lazy_static;
use std::{
process,
sync::{atomic::AtomicBool, mpsc::channel, Arc},
};
use std::sync::{atomic::AtomicBool, mpsc::channel, Arc};
use crossfire::mpsc::unbounded_future;
@ -29,6 +27,7 @@ use bridge::start_bridge;
use editor::start_editor;
use renderer::{cursor_renderer::CursorSettings, RendererSettings};
use window::{create_window, window_geometry, KeyboardSettings, WindowSettings};
use windows_utils::attach_parent_console;
pub const INITIAL_DIMENSIONS: (u64, u64) = (100, 50);
@ -101,11 +100,22 @@ fn main() {
// another frame next frame, or if it can safely skip drawing to save battery and cpu power.
// Multiple other parts of the app "queue_next_frame" function to ensure animations continue
// properly or updates to the graphics are pushed to the screen.
println!("This is a test");
if std::env::args().any(|arg| arg == "--version" || arg == "-v") {
attach_parent_console();
println!("Neovide version: {}", env!("CARGO_PKG_VERSION"));
}
if std::env::args().any(|arg| arg == "--help" || arg == "-h") {
attach_parent_console();
println!("Neovide: {}", env!("CARGO_PKG_DESCRIPTION"));
}
if let Err(err) = window_geometry() {
eprintln!("{}", err);
process::exit(1);
};
return;
}
#[cfg(target_os = "macos")]
{
@ -118,7 +128,6 @@ fn main() {
.arg("--disowned")
.spawn()
.is_ok());
std::process::exit(0);
} else {
eprintln!("error in disowning process, cannot obtain the path for the current executable, continuing without disowning...");
}

@ -12,7 +12,6 @@ use nvim_rs::Neovim;
use parking_lot::RwLock;
pub use rmpv::Value;
use tokio::process::ChildStdin;
pub mod windows_registry;
use crate::error_handling::ResultPanicExplanation;
@ -50,14 +49,12 @@ impl Settings {
if arg == "--log" {
log_to_file = true;
false
} else if arg == "--version" || arg == "-v" {
println!("Neovide version: {}", env!("CARGO_PKG_VERSION"));
std::process::exit(0);
} else if arg == "--help" || arg == "-h" {
println!("neovide: {}", env!("CARGO_PKG_DESCRIPTION"));
std::process::exit(0);
} else {
!(arg.starts_with("--geometry=")
|| arg == "--version"
|| arg == "-v"
|| arg == "--help"
|| arg == "-h"
|| arg == "--wsl"
|| arg == "--disowned"
|| arg == "--multiGrid"

@ -5,6 +5,7 @@ use winapi::{
shared::minwindef::{DWORD, HKEY, MAX_PATH},
um::{
libloaderapi::GetModuleFileNameA,
wincon::{AttachConsole, ATTACH_PARENT_PROCESS},
winnt::{KEY_WRITE, REG_OPTION_NON_VOLATILE, REG_SZ},
winreg::{RegCloseKey, RegCreateKeyExA, RegDeleteTreeA, RegSetValueExA, HKEY_CLASSES_ROOT},
},
@ -212,3 +213,9 @@ pub fn register_rightclick_file() -> bool {
}
true
}
pub fn attach_parent_console() {
unsafe {
AttachConsole(ATTACH_PARENT_PROCESS);
}
}
Loading…
Cancel
Save