Skip to content

Commit 1b1ecbe

Browse files
committed
Accept both data dir and DB file paths.
1 parent 215899c commit 1b1ecbe

File tree

2 files changed

+22
-11
lines changed

2 files changed

+22
-11
lines changed

README.md

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,25 @@ The key must be 64 hexadecimal characters, meaning 32 bytes (256 bits).
4848

4949
### Installed Binaries
5050

51-
- `asimov-signal-reader`
51+
- `asimov-signal-reader`: reads chats from the Signal data directory
5252

5353
### `asimov-signal-reader`
5454

5555
```
5656
asimov-signal-reader
5757
58-
Usage: asimov-signal-reader [OPTIONS]
58+
Usage: asimov-signal-reader [OPTIONS] [SIGNAL-DIR]
59+
60+
Arguments:
61+
[SIGNAL-DIR] Path to the Signal data directory
5962
6063
Options:
61-
-d, --debug Enable debugging output
62-
--license Show license information
63-
-v, --verbose... Enable verbose output (may be repeated for more verbosity)
64-
-V, --version Print version information
65-
-h, --help Print help
64+
-d, --debug Enable debugging output
65+
--license Show license information
66+
-v, --verbose... Enable verbose output (may be repeated for more verbosity)
67+
-V, --version Print version information
68+
-o, --output <FORMAT> Set the output format [default: jsonl] [possible values: jsonl]
69+
-h, --help Print help
6670
```
6771

6872
## 👨‍💻 Development

src/reader/main.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{error::Error, io::Write, path::PathBuf};
1717

1818
/// asimov-signal-reader
1919
#[derive(Debug, Parser)]
20-
#[command(arg_required_else_help = true)]
20+
#[command(arg_required_else_help = false)]
2121
struct Options {
2222
#[clap(flatten)]
2323
flags: StandardOptions,
@@ -26,8 +26,8 @@ struct Options {
2626
#[arg(value_name = "FORMAT", short = 'o', long)]
2727
output: Option<String>,
2828

29-
/// Path to the (unencrypted!) Signal database file
30-
#[clap(value_name = "SIGNAL-DB-FILE", default_value = default_signal_path().into_os_string())]
29+
/// Path to the Signal data directory
30+
#[clap(value_name = "SIGNAL-DIR", default_value = default_signal_path().into_os_string())]
3131
path: PathBuf,
3232
}
3333

@@ -57,10 +57,17 @@ pub fn main() -> Result<SysexitsError, Box<dyn Error>> {
5757
#[cfg(feature = "tracing")]
5858
asimov_module::init_tracing_subscriber(&options.flags).expect("failed to initialize logging");
5959

60+
let path = &options.path;
61+
let db_path = if path.ends_with(".sqlite") {
62+
path.clone()
63+
} else {
64+
path.join("sql/db.sqlite")
65+
};
66+
6067
let key = asimov_module::getenv::var_secret("ASIMOV_SIGNAL_KEY");
6168

6269
let Ok(conn) = Connection::open_with_flags(
63-
&options.path,
70+
db_path,
6471
OpenFlags::SQLITE_OPEN_READ_ONLY
6572
| OpenFlags::SQLITE_OPEN_URI
6673
| OpenFlags::SQLITE_OPEN_NO_MUTEX

0 commit comments

Comments
 (0)