Skip to content

Commit 215899c

Browse files
committed
Default to platform-specific paths.
1 parent 77896fc commit 215899c

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ unstable = []
2828
asimov-module = { version = "25.0.0-dev.18", default-features = true }
2929
clap = { version = "4.5", default-features = false, features = [
3030
"std",
31+
"string",
3132
], optional = true }
3233
clientele = { version = "0.3.8", default-features = false, features = [
3334
"clap",

src/dir.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This is free and unencumbered software released into the public domain.
2+
3+
#[derive(Debug)]
4+
pub struct SignalDir {}

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,11 @@ extern crate alloc;
77

88
mod classes;
99
pub use classes::*;
10+
11+
mod dir;
12+
pub use dir::*;
13+
14+
#[cfg(feature = "std")]
15+
mod path;
16+
#[cfg(feature = "std")]
17+
pub use path::*;

src/path.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// This is free and unencumbered software released into the public domain.
2+
3+
extern crate std;
4+
5+
use asimov_module::getenv;
6+
use std::path::PathBuf;
7+
8+
#[cfg(unix)]
9+
/// See: https://support.signal.org/hc/en-us/articles/360007059752-Backup-and-Restore-Messages
10+
/// See: https://github.com/signalapp/Signal-Desktop/blob/main/CONTRIBUTING.md#the-staging-environment
11+
pub fn default_signal_path() -> PathBuf {
12+
let mut result: PathBuf = getenv::home().unwrap().into();
13+
#[cfg(target_os = "macos")]
14+
result.push("Library/Application Support/Signal");
15+
#[cfg(not(target_os = "macos"))]
16+
result.push(".config/Signal");
17+
result
18+
}
19+
20+
#[cfg(windows)]
21+
/// See: https://support.signal.org/hc/en-us/articles/360007059752-Backup-and-Restore-Messages
22+
/// See: https://github.com/signalapp/Signal-Desktop/blob/main/CONTRIBUTING.md#the-staging-environment
23+
pub fn default_signal_path() -> PathBuf {
24+
let mut result: PathBuf = getenv::appdata().unwrap().into();
25+
#[cfg(target_os = "windows")]
26+
result.push(r"Roaming\Signal");
27+
result
28+
}
29+
30+
#[cfg(all(not(unix), not(windows)))]
31+
pub fn default_signal_path() -> PathBuf {
32+
todo!("implement default_signal_path for this platform") // TODO
33+
}

src/reader/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use asimov_module::{
88
json::SkipNulls,
99
secrecy::ExposeSecret,
1010
};
11+
use asimov_signal_module::default_signal_path;
1112
use clap::Parser;
1213
use clientele::StandardOptions;
1314
use rusqlite::{Connection, OpenFlags, Result};
@@ -26,7 +27,7 @@ struct Options {
2627
output: Option<String>,
2728

2829
/// Path to the (unencrypted!) Signal database file
29-
#[clap(value_name = "SIGNAL-DB-FILE")]
30+
#[clap(value_name = "SIGNAL-DB-FILE", default_value = default_signal_path().into_os_string())]
3031
path: PathBuf,
3132
}
3233

0 commit comments

Comments
 (0)