json_archive/flags.rs
1// json-archive is a tool for tracking JSON file changes over time
2// Copyright (C) 2025 Peoples Grocers LLC
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU Affero General Public License as published
6// by the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU Affero General Public License for more details.
13//
14// You should have received a copy of the GNU Affero General Public License
15// along with this program. If not, see <https://www.gnu.org/licenses/>.
16//
17// To purchase a license under different terms contact admin@peoplesgrocers.com
18// To request changes, report bugs, or give user feedback contact
19// marxism@peoplesgrocers.com
20//
21
22use std::path::PathBuf;
23
24xflags::xflags! {
25 cmd json-archive {
26 default cmd write {
27 /// Input JSON files in chronological order. If first file is a .json.archive file,
28 /// appends remaining files to it. Otherwise creates a new archive from all files.
29 repeated inputs: PathBuf
30
31 /// Output archive file path. Defaults to <first-input>.json.archive for new archives,
32 /// or to the archive path itself when appending (in-place update). Use -o to write
33 /// the result to a different location.
34 optional -o, --output output: PathBuf
35
36 /// Insert snapshot every N observations (optional)
37 optional -s, --snapshot-interval snapshot_interval: usize
38
39 /// Source identifier for archive metadata
40 optional --source source: String
41 }
42
43 cmd info {
44 /// Archive file to show information about
45 required file: PathBuf
46
47 /// Output format: human-readable (default) or json
48 optional --output output: String
49 }
50
51 cmd state {
52 /// Archive file to read state from
53 required file: PathBuf
54
55 /// Get state at specific observation ID
56 optional --id id: String
57
58 /// Get state at Nth observation in file order (not chronological)
59 optional --index index: usize
60
61 /// Get state as of this timestamp (most recent observation <= timestamp)
62 optional --as-of as_of: String
63
64 /// Get state right before this timestamp (most recent observation < timestamp)
65 optional --before before: String
66
67 /// Get state after this timestamp (earliest observation > timestamp)
68 optional --after after: String
69
70 /// Get latest state by timestamp (default if no other flags specified)
71 optional --latest latest: bool
72 }
73 }
74}