liboci_cli/
lib.rs

1use std::fmt::Debug;
2use std::path::PathBuf;
3
4use clap::Parser;
5
6// Subcommands that are specified in https://github.com/opencontainers/runtime-tools/blob/master/docs/command-line-interface.md
7
8mod create;
9mod delete;
10mod kill;
11mod start;
12mod state;
13
14pub use create::Create;
15pub use delete::Delete;
16pub use kill::Kill;
17pub use start::Start;
18pub use state::State;
19
20// Other common subcommands that aren't specified in the document
21mod checkpoint;
22mod events;
23mod exec;
24mod features;
25mod list;
26mod pause;
27mod ps;
28mod resume;
29mod run;
30mod spec;
31mod update;
32
33pub use checkpoint::Checkpoint;
34pub use events::Events;
35pub use exec::Exec;
36pub use features::Features;
37pub use list::List;
38pub use pause::Pause;
39pub use ps::Ps;
40pub use resume::Resume;
41pub use run::Run;
42pub use spec::Spec;
43pub use update::Update;
44
45// Subcommands parsed by liboci-cli, based on the [OCI
46// runtime-spec](https://github.com/opencontainers/runtime-spec/blob/master/runtime.md)
47// and specifically the [OCI Command Line
48// Interface](https://github.com/opencontainers/runtime-tools/blob/master/docs/command-line-interface.md)
49#[derive(Parser, Debug)]
50pub enum StandardCmd {
51    Create(Create),
52    Start(Start),
53    State(State),
54    Kill(Kill),
55    Delete(Delete),
56}
57
58// Extra subcommands not documented in the OCI Command Line Interface,
59// but found in
60// [runc](https://github.com/opencontainers/runc/blob/master/man/runc.8.md)
61// and other runtimes.
62#[derive(Parser, Debug)]
63pub enum CommonCmd {
64    Checkpointt(Checkpoint),
65    Events(Events),
66    Exec(Exec),
67    Features(Features),
68    List(List),
69    Pause(Pause),
70    #[clap(allow_hyphen_values = true)]
71    Ps(Ps),
72    Resume(Resume),
73    Run(Run),
74    Update(Update),
75    Spec(Spec),
76}
77
78// The OCI Command Line Interface document doesn't define any global
79// flags, but these are commonly accepted by runtimes
80#[derive(Parser, Debug)]
81pub struct GlobalOpts {
82    /// set the log file to write youki logs to (default is '/dev/stderr')
83    #[clap(short, long, overrides_with("log"))]
84    pub log: Option<PathBuf>,
85    /// change log level to debug, but the `log-level` flag takes precedence
86    #[clap(long)]
87    pub debug: bool,
88    /// set the log format ('text' (default), or 'json') (default: "text")
89    #[clap(long)]
90    pub log_format: Option<String>,
91    /// root directory to store container state
92    #[clap(short, long)]
93    pub root: Option<PathBuf>,
94    /// Enable systemd cgroup manager, rather then use the cgroupfs directly.
95    #[clap(short, long)]
96    pub systemd_cgroup: bool,
97}