Skip to main content

liboci_cli/
lib.rs

1use std::fmt::Debug;
2use std::path::PathBuf;
3
4use clap::{Args, Subcommand};
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(Subcommand, 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(Subcommand, Debug)]
63pub enum CommonCmd {
64    Checkpointt(Checkpoint),
65    Events(Events),
66    Exec(Exec),
67    Features(Features),
68    List(List),
69    Pause(Pause),
70    Ps(Ps),
71    Resume(Resume),
72    Run(Run),
73    Update(Update),
74    Spec(Spec),
75}
76
77// The OCI Command Line Interface document doesn't define any global
78// flags, but these are commonly accepted by runtimes
79#[derive(Args, Debug)]
80pub struct GlobalOpts {
81    /// set the log file to write youki logs to (default is '/dev/stderr')
82    #[arg(short, long, overrides_with("log"))]
83    pub log: Option<PathBuf>,
84    /// change log level to debug, but the `log-level` flag takes precedence
85    #[arg(long)]
86    pub debug: bool,
87    /// set the log format ('text' (default), or 'json') (default: "text")
88    #[arg(long)]
89    pub log_format: Option<String>,
90    /// root directory to store container state
91    #[arg(short, long)]
92    pub root: Option<PathBuf>,
93    /// Enable systemd cgroup manager, rather then use the cgroupfs directly.
94    #[arg(short, long)]
95    pub systemd_cgroup: bool,
96}