Skip to content

Commit 0c58894

Browse files
committed
chore: make cli module public
We need the cli in both the binary and the library, which are separate crates. In order to keep it private, we were compiling it twice, incurring costs to compilation time and binary size. This is not worth it.
1 parent b5daa5c commit 0c58894

File tree

8 files changed

+28
-33
lines changed

8 files changed

+28
-33
lines changed

Diff for: devenv/src/cli.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ use std::path::PathBuf;
1010
dont_delimit_trailing_values = true,
1111
about = format!("https://devenv.sh {}: Fast, Declarative, Reproducible, and Composable Developer Environments", crate_version!())
1212
)]
13-
pub(crate) struct Cli {
13+
pub struct Cli {
1414
#[command(subcommand)]
15-
pub(crate) command: Commands,
15+
pub command: Commands,
1616

1717
#[command(flatten)]
18-
pub(crate) global_options: GlobalOptions,
18+
pub global_options: GlobalOptions,
1919
}
2020

2121
impl Cli {
@@ -158,7 +158,7 @@ impl GlobalOptions {
158158
}
159159

160160
#[derive(Subcommand, Clone)]
161-
pub(crate) enum Commands {
161+
pub enum Commands {
162162
#[command(about = "Scaffold devenv.yaml, devenv.nix, .gitignore and .envrc.")]
163163
Init {
164164
target: Option<PathBuf>,
@@ -270,7 +270,7 @@ pub(crate) enum Commands {
270270

271271
#[derive(Subcommand, Clone)]
272272
#[clap(about = "Start or stop processes. https://devenv.sh/processes/")]
273-
pub(crate) enum ProcessesCommand {
273+
pub enum ProcessesCommand {
274274
#[command(alias = "start", about = "Start processes in the foreground.")]
275275
Up {
276276
process: Option<String>,
@@ -286,7 +286,7 @@ pub(crate) enum ProcessesCommand {
286286

287287
#[derive(Subcommand, Clone)]
288288
#[clap(about = "Run tasks. https://devenv.sh/tasks/")]
289-
pub(crate) enum TasksCommand {
289+
pub enum TasksCommand {
290290
#[command(about = "Run tasks.")]
291291
Run { tasks: Vec<String> },
292292
}
@@ -296,7 +296,7 @@ pub(crate) enum TasksCommand {
296296
about = "Build, copy, or run a container. https://devenv.sh/containers/",
297297
arg_required_else_help(true)
298298
)]
299-
pub(crate) enum ContainerCommand {
299+
pub enum ContainerCommand {
300300
#[command(about = "Build a container.")]
301301
Build { name: String },
302302

@@ -309,7 +309,7 @@ pub(crate) enum ContainerCommand {
309309

310310
#[derive(Subcommand, Clone)]
311311
#[clap(about = "Add an input to devenv.yaml. https://devenv.sh/inputs/")]
312-
pub(crate) enum InputsCommand {
312+
pub enum InputsCommand {
313313
#[command(about = "Add an input to devenv.yaml.")]
314314
Add {
315315
#[arg(help = "The name of the input.")]

Diff for: devenv/src/devenv.rs

+11-9
Original file line numberDiff line numberDiff line change
@@ -34,28 +34,30 @@ pub struct DevenvOptions {
3434
}
3535

3636
pub struct Devenv {
37-
pub(crate) config: config::Config,
38-
pub(crate) global_options: cli::GlobalOptions,
37+
pub config: config::Config,
38+
pub global_options: cli::GlobalOptions,
3939

40-
pub(crate) logger: log::Logger,
41-
pub(crate) log_progress: log::LogProgressCreator,
40+
logger: log::Logger,
41+
log_progress: log::LogProgressCreator,
4242

4343
nix: cnix::Nix<'static>,
4444

4545
// All kinds of paths
4646
xdg_dirs: xdg::BaseDirectories,
47-
pub(crate) devenv_root: PathBuf,
47+
devenv_root: PathBuf,
4848
devenv_dotfile: PathBuf,
4949
devenv_dot_gc: PathBuf,
5050
devenv_home_gc: PathBuf,
5151
devenv_tmp: String,
5252
devenv_runtime: PathBuf,
5353

54-
pub(crate) assembled: bool,
55-
pub(crate) dirs_created: bool,
56-
pub(crate) has_processes: Option<bool>,
54+
assembled: bool,
55+
dirs_created: bool,
56+
has_processes: Option<bool>,
5757

58-
pub(crate) container_name: Option<String>,
58+
// TODO: make private.
59+
// Pass as an arg or have a setter.
60+
pub container_name: Option<String>,
5961
}
6062

6163
impl Devenv {

Diff for: devenv/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
mod cli;
2-
pub mod cnix;
1+
pub mod cli;
2+
pub(crate) mod cnix;
33
pub mod config;
44
mod devenv;
55
pub mod log;

Diff for: devenv/src/main.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,8 @@
1-
mod cli;
2-
mod cnix;
3-
mod config;
4-
mod devenv;
5-
mod log;
6-
mod tasks;
7-
8-
use clap::{crate_version, Parser};
9-
use cli::{Cli, Commands, ContainerCommand, InputsCommand, ProcessesCommand, TasksCommand};
10-
use devenv::Devenv;
1+
use clap::crate_version;
2+
use devenv::{
3+
cli::{Cli, Commands, ContainerCommand, InputsCommand, ProcessesCommand, TasksCommand},
4+
config, log, Devenv,
5+
};
116
use miette::Result;
127

138
#[tokio::main]

Diff for: xtask/src/cli.rs

-1
This file was deleted.

Diff for: xtask/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
pub(crate) mod cli;
21
pub mod manpage;
32
pub mod shell_completion;

Diff for: xtask/src/manpage.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use super::cli::Cli;
21
use clap::CommandFactory;
2+
use devenv::cli::Cli;
33
use miette::{IntoDiagnostic, Result};
44
use std::fs;
55
use std::path::{Path, PathBuf};

Diff for: xtask/src/shell_completion.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use crate::cli::Cli;
21
use clap::CommandFactory;
2+
use devenv::cli::Cli;
33
use miette::{IntoDiagnostic, Result};
44
use std::fs;
55
use std::path::{Path, PathBuf};

0 commit comments

Comments
 (0)