feat: add si command line interface (#37)
Reviewed-on: #37
This commit was merged in pull request #37.
This commit is contained in:
+18
-1
@@ -3,7 +3,8 @@ use std::sync::LazyLock;
|
||||
|
||||
/// The application name, which derives the platform-specific directory paths.
|
||||
pub const APP_NAME: &str = "Signed";
|
||||
|
||||
/// The application's platform identifier, the packager `identifier` in `desktop/Cargo.toml`.
|
||||
pub const APP_ID: &str = "build.signed.signed";
|
||||
/// Lowercased [`APP_NAME`], used in XDG paths and the macOS `~/.config` fallback.
|
||||
pub const APP_NAME_LOWERCASE: &str = "signed";
|
||||
|
||||
@@ -72,6 +73,22 @@ pub fn documents_dir() -> PathBuf {
|
||||
dirs::document_dir().unwrap_or_else(|| dirs::home_dir().unwrap_or_default())
|
||||
}
|
||||
|
||||
/// The binary named `name` built next to the running executable, when it is there.
|
||||
pub fn sibling_binary(name: &str) -> Option<PathBuf> {
|
||||
let name = if std::env::consts::EXE_EXTENSION.is_empty() {
|
||||
name.to_owned()
|
||||
} else {
|
||||
format!("{name}.{}", std::env::consts::EXE_EXTENSION)
|
||||
};
|
||||
let binary = std::env::current_exe().ok()?.with_file_name(name);
|
||||
binary.is_file().then_some(binary)
|
||||
}
|
||||
|
||||
/// Returns the user's binary folder, `~/.local/bin`, which most shells put on the PATH.
|
||||
pub fn user_bin_dir() -> PathBuf {
|
||||
home_dir().join(".local").join("bin")
|
||||
}
|
||||
|
||||
fn config_dir() -> &'static Path {
|
||||
CONFIG_DIR.as_path()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user