add separate binary for Windows CLI
This commit is contained in:
		| @@ -1,6 +1,6 @@ | |||||||
| { | { | ||||||
|   "name": "creddy", |   "name": "creddy", | ||||||
|   "version": "0.2.1", |   "version": "0.2.2", | ||||||
|   "scripts": { |   "scripts": { | ||||||
|     "dev": "vite", |     "dev": "vite", | ||||||
|     "build": "vite build", |     "build": "vite build", | ||||||
|   | |||||||
							
								
								
									
										60
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										60
									
								
								src-tauri/Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -68,36 +68,6 @@ version = "1.0.71" | |||||||
| source = "registry+https://github.com/rust-lang/crates.io-index" | source = "registry+https://github.com/rust-lang/crates.io-index" | ||||||
| checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" | checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" | ||||||
|  |  | ||||||
| [[package]] |  | ||||||
| name = "app" |  | ||||||
| version = "0.2.1" |  | ||||||
| dependencies = [ |  | ||||||
|  "argon2", |  | ||||||
|  "auto-launch", |  | ||||||
|  "aws-config", |  | ||||||
|  "aws-sdk-sts", |  | ||||||
|  "aws-smithy-types", |  | ||||||
|  "aws-types", |  | ||||||
|  "chacha20poly1305", |  | ||||||
|  "clap", |  | ||||||
|  "dirs 5.0.1", |  | ||||||
|  "is-terminal", |  | ||||||
|  "netstat2", |  | ||||||
|  "once_cell", |  | ||||||
|  "serde", |  | ||||||
|  "serde_json", |  | ||||||
|  "sodiumoxide", |  | ||||||
|  "sqlx", |  | ||||||
|  "strum", |  | ||||||
|  "strum_macros", |  | ||||||
|  "sysinfo", |  | ||||||
|  "tauri", |  | ||||||
|  "tauri-build", |  | ||||||
|  "tauri-plugin-single-instance", |  | ||||||
|  "thiserror", |  | ||||||
|  "tokio", |  | ||||||
| ] |  | ||||||
|  |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "argon2" | name = "argon2" | ||||||
| version = "0.5.0" | version = "0.5.0" | ||||||
| @@ -975,6 +945,36 @@ dependencies = [ | |||||||
|  "cfg-if", |  "cfg-if", | ||||||
| ] | ] | ||||||
|  |  | ||||||
|  | [[package]] | ||||||
|  | name = "creddy" | ||||||
|  | version = "0.2.2" | ||||||
|  | dependencies = [ | ||||||
|  |  "argon2", | ||||||
|  |  "auto-launch", | ||||||
|  |  "aws-config", | ||||||
|  |  "aws-sdk-sts", | ||||||
|  |  "aws-smithy-types", | ||||||
|  |  "aws-types", | ||||||
|  |  "chacha20poly1305", | ||||||
|  |  "clap", | ||||||
|  |  "dirs 5.0.1", | ||||||
|  |  "is-terminal", | ||||||
|  |  "netstat2", | ||||||
|  |  "once_cell", | ||||||
|  |  "serde", | ||||||
|  |  "serde_json", | ||||||
|  |  "sodiumoxide", | ||||||
|  |  "sqlx", | ||||||
|  |  "strum", | ||||||
|  |  "strum_macros", | ||||||
|  |  "sysinfo", | ||||||
|  |  "tauri", | ||||||
|  |  "tauri-build", | ||||||
|  |  "tauri-plugin-single-instance", | ||||||
|  |  "thiserror", | ||||||
|  |  "tokio", | ||||||
|  | ] | ||||||
|  |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "crossbeam-channel" | name = "crossbeam-channel" | ||||||
| version = "0.5.8" | version = "0.5.8" | ||||||
|   | |||||||
| @@ -1,14 +1,22 @@ | |||||||
| [package] | [package] | ||||||
| name = "app" | name = "creddy" | ||||||
| version = "0.2.1" | version = "0.2.2" | ||||||
| description = "A Tauri App" | description = "A friendly AWS credentials manager" | ||||||
| authors = ["you"] | authors = ["Joseph Montanaro"] | ||||||
| license = "" | license = "" | ||||||
| repository = "" | repository = "" | ||||||
| default-run = "app" | default-run = "creddy" | ||||||
| edition = "2021" | edition = "2021" | ||||||
| rust-version = "1.57" | rust-version = "1.57" | ||||||
|  |  | ||||||
|  | [[bin]] | ||||||
|  | name = "creddy_cli" | ||||||
|  | path = "src/bin/creddy_cli.rs" | ||||||
|  |  | ||||||
|  | [[bin]] | ||||||
|  | name = "creddy" | ||||||
|  | path = "src/main.rs" | ||||||
|  |  | ||||||
| # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||||||
|  |  | ||||||
| [build-dependencies] | [build-dependencies] | ||||||
|   | |||||||
							
								
								
									
										22
									
								
								src-tauri/conf/cli.wxs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								src-tauri/conf/cli.wxs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | |||||||
|  | <?xml version="1.0" encoding="utf-8"?> | ||||||
|  | <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"> | ||||||
|  |     <Fragment> | ||||||
|  |  | ||||||
|  |         <DirectoryRef Id="INSTALLDIR"> | ||||||
|  |             <!-- Create a subdirectory for the console binary so that we can add it to PATH --> | ||||||
|  |             <Directory Id="BinDir" Name="bin"> | ||||||
|  |                 <Component Id="CliBinary" Guid="b6358c8e-504f-41fd-b14b-38af821dcd04"> | ||||||
|  |                     <!-- Same name as the main executable, so that it can be invoked as just "creddy" --> | ||||||
|  |                     <File Id="Bin_Cli" Source="..\..\creddy_cli.exe" Name="creddy.exe" KeyPath="yes"/> | ||||||
|  |                 </Component> | ||||||
|  |             </Directory> | ||||||
|  |         </DirectoryRef> | ||||||
|  |  | ||||||
|  |         <DirectoryRef Id="TARGETDIR"> | ||||||
|  |             <Component Id="AddToPath" Guid="b5fdaf7e-94f2-4aad-9144-aa3a8edfa675"> | ||||||
|  |                 <Environment Id="CreddyInstallDir" Action="set" Name="PATH" Part="last" Permanent="no" Value="[BinDir]" /> | ||||||
|  |             </Component> | ||||||
|  |         </DirectoryRef> | ||||||
|  |  | ||||||
|  |     </Fragment> | ||||||
|  | </Wix> | ||||||
							
								
								
									
										45
									
								
								src-tauri/src/bin/creddy_cli.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										45
									
								
								src-tauri/src/bin/creddy_cli.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,45 @@ | |||||||
|  | // Windows isn't really amenable to having a single executable work as both a CLI and GUI app, | ||||||
|  | // so we just have a second binary for CLI usage | ||||||
|  | use creddy::{ | ||||||
|  |     cli, | ||||||
|  |     errors::CliError, | ||||||
|  | }; | ||||||
|  | use std::{ | ||||||
|  |     env, | ||||||
|  |     process::{self, Command}, | ||||||
|  | }; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | fn main() { | ||||||
|  |     let args = cli::parser().get_matches(); | ||||||
|  |     if let Some(true) = args.get_one::<bool>("help") { | ||||||
|  |         cli::parser().print_help().unwrap(); // if we can't print help we can't print an error | ||||||
|  |         process::exit(0); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     let res = match args.subcommand() { | ||||||
|  |         None | Some(("run", _)) => launch_gui(), | ||||||
|  |         Some(("show", m)) => cli::show(m), | ||||||
|  |         Some(("exec", m)) => cli::exec(m), | ||||||
|  |         _ => unreachable!(), | ||||||
|  |     }; | ||||||
|  |  | ||||||
|  |     if let Err(e) = res { | ||||||
|  |         eprintln!("Error: {e}"); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | fn launch_gui() -> Result<(), CliError>  { | ||||||
|  |     let mut path = env::current_exe()?; | ||||||
|  |     path.pop(); // bin dir | ||||||
|  |      | ||||||
|  |     // binaries are colocated in dev, but not in production | ||||||
|  |     #[cfg(not(debug_assertions))] | ||||||
|  |     path.pop(); // install dir | ||||||
|  |  | ||||||
|  |     path.push("creddy.exe"); // exe in main install dir (aka gui exe) | ||||||
|  |  | ||||||
|  |     Command::new(path).spawn()?; | ||||||
|  |     Ok(()) | ||||||
|  | } | ||||||
| @@ -228,6 +228,8 @@ pub enum CliError { | |||||||
|     Request(#[from] RequestError), |     Request(#[from] RequestError), | ||||||
|     #[error(transparent)] |     #[error(transparent)] | ||||||
|     Exec(#[from] ExecError), |     Exec(#[from] ExecError), | ||||||
|  |     #[error(transparent)] | ||||||
|  |     Io(#[from] std::io::Error), | ||||||
| } | } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										10
									
								
								src-tauri/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10
									
								
								src-tauri/src/lib.rs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,10 @@ | |||||||
|  | pub mod app; | ||||||
|  | pub mod cli; | ||||||
|  | mod config; | ||||||
|  | mod credentials; | ||||||
|  | pub mod errors; | ||||||
|  | mod clientinfo; | ||||||
|  | mod ipc; | ||||||
|  | mod state; | ||||||
|  | mod server; | ||||||
|  | mod tray; | ||||||
| @@ -3,20 +3,11 @@ | |||||||
|     windows_subsystem = "windows" |     windows_subsystem = "windows" | ||||||
| )] | )] | ||||||
|  |  | ||||||
|  | use creddy::{ | ||||||
| mod app; |     app, | ||||||
| mod cli; |     cli, | ||||||
| mod config; |     errors::ErrorPopup, | ||||||
| mod credentials; | }; | ||||||
| mod errors; |  | ||||||
| mod clientinfo; |  | ||||||
| mod ipc; |  | ||||||
| mod state; |  | ||||||
| mod server; |  | ||||||
| mod tray; |  | ||||||
|  |  | ||||||
|  |  | ||||||
| use crate::errors::ErrorPopup; |  | ||||||
|  |  | ||||||
|  |  | ||||||
| fn main() { | fn main() { | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ | |||||||
|   }, |   }, | ||||||
|   "package": { |   "package": { | ||||||
|     "productName": "creddy", |     "productName": "creddy", | ||||||
|     "version": "0.2.1" |     "version": "0.2.2" | ||||||
|   }, |   }, | ||||||
|   "tauri": { |   "tauri": { | ||||||
|     "allowlist": { |     "allowlist": { | ||||||
| @@ -44,7 +44,11 @@ | |||||||
|       "windows": { |       "windows": { | ||||||
|         "certificateThumbprint": null, |         "certificateThumbprint": null, | ||||||
|         "digestAlgorithm": "sha256", |         "digestAlgorithm": "sha256", | ||||||
|         "timestampUrl": "" |         "timestampUrl": "", | ||||||
|  |         "wix": { | ||||||
|  |           "fragmentPaths": ["conf/cli.wxs"], | ||||||
|  |           "componentRefs": ["CliBinary", "AddToPath"] | ||||||
|  |         } | ||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "security": { |     "security": { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user