Skip to content

Commit bb17f25

Browse files
committed
Improve rig repos available
- compact table by default - new `rig repos available <name>` with nicer output.
1 parent bd8ecab commit bb17f25

6 files changed

Lines changed: 562 additions & 45 deletions

File tree

NEWS.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
* rig now does not edit the shell startup files in admin mode,
44
like rig 0.8.1 did on macOS. rig now only does this in user mode.
55

6+
* `rig repos available` now prints a compact table. New
7+
`rig repos available <name>` shows complete information about a single
8+
repository.
9+
610
# rig 0.10.0-alpha2 (pre-release)
711

812
* rig now supports a **user mode** on all platforms, in addition to the

src/args.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,6 +1476,11 @@ pub fn rig_app() -> Command {
14761476
.long("json")
14771477
.num_args(0)
14781478
.required(false),
1479+
)
1480+
.arg(
1481+
Arg::new("name")
1482+
.help("Repository to show in detail, e.g. 'P3M' (case insensitive)")
1483+
.required(false),
14791484
),
14801485
)
14811486
.subcommand(

src/help-generated.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const HELP_PROJ_SOLVE: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[2
4343
const ABOUT_PROJ: &str = "Manage R projects (experimental)";
4444
const HELP_PROJ: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n Manage R projects (experimental).\n\n A project is a directory with a package manifest, typically a\n \u{1b}[32mDESCRIPTION\u{1b}[39m file, that declares the R packages the project depends on.\n \u{1b}[32mrig proj\u{1b}[39m resolves those dependencies against the configured package\n repositories and can install them into a project library.\n\n \u{1b}[32mrig proj deps\u{1b}[39m shows the direct and recursive dependencies of the\n project.\n \u{1b}[32mrig proj solve\u{1b}[39m resolves the full dependency tree to a concrete set of\n package versions, and can write the result to an \u{1b}[32mrenv.lock\u{1b}[39m file.\n \u{1b}[32mrig proj deploy\u{1b}[39m installs the resolved dependencies into a package\n library.\n\n Dependencies are resolved with rig's built-in solver, so R does not need\n to be running for \u{1b}[32mrig proj deps\u{1b}[39m and \u{1b}[32mrig proj solve\u{1b}[39m.\n\n \u{1b}[32mrig proj\u{1b}[39m is currently experimental, and might change in future\n versions. Feedback is appreciated.";
4545
const ABOUT_REPOS_AVAILABLE: &str = "List available R package repositories";
46-
const HELP_REPOS_AVAILABLE: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the package repositories that rig knows about and can set up.\n\n These are the repositories you can enable with \u{1b}[32m--with-repos\u{1b}[39m when running\n \u{1b}[32mrig add\u{1b}[39m or \u{1b}[32mrig repos setup\u{1b}[39m.";
46+
const HELP_REPOS_AVAILABLE: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the package repositories that rig knows about and can set up.\n\n These are the repositories you can enable with \u{1b}[32m--with-repos\u{1b}[39m when running\n \u{1b}[32mrig add\u{1b}[39m or \u{1b}[32mrig repos setup\u{1b}[39m.\n\n Without arguments rig prints one row per repository: its name, whether it is\n part of the default repository set, and its title.\n\n Pass a repository name to see its description and its URLs, together with the\n platforms, architectures and R versions each URL applies to. Repository names\n are matched case insensitively.\n\n\u{1b}[1m\u{1b}[34mExamples:\u{1b}[39m\u{1b}[22m\n # List all repositories rig knows about\n rig repos available\n\n # Show the URLs of one repository\n rig repos available P3M";
4747
const ABOUT_REPOS_LIST: &str = "List configured R package repositories";
4848
const HELP_REPOS_LIST: &str = "\u{1b}[1m\u{1b}[34mDescription:\u{1b}[39m\u{1b}[22m\n List the package repositories configured for an R version.\n\n By default rig shows the repositories of the default R version; use\n \u{1b}[32m--r-version\u{1b}[39m to pick another. Add \u{1b}[32m--all\u{1b}[39m to include repositories that\n are not enabled by default, and \u{1b}[32m--raw\u{1b}[39m to show repository URLs without\n resolving the \u{1b}[32m%\u{1b}[39m variables in them.";
4949
const ABOUT_REPOS_PACKAGE_INFO: &str = "Information about the package in the repositories";

src/help/repos-available.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,20 @@ List the package repositories that rig knows about and can set up.
66

77
These are the repositories you can enable with `--with-repos` when running
88
`rig add` or `rig repos setup`.
9+
10+
Without arguments rig prints one row per repository: its name, whether it is
11+
part of the default repository set, and its title.
12+
13+
Pass a repository name to see its description and its URLs, together with the
14+
platforms, architectures and R versions each URL applies to. Repository names
15+
are matched case insensitively.
16+
17+
## Examples
18+
19+
```sh
20+
# List all repositories rig knows about
21+
rig repos available
22+
23+
# Show the URLs of one repository
24+
rig repos available P3M
25+
```

src/repos/config.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,6 @@ pub enum Enabled {
1111
OnPlatforms { platforms: Vec<String> },
1212
}
1313

14-
impl Enabled {
15-
/// A short human-readable description of the default-enabled state, used by
16-
/// `rig repos list`.
17-
pub fn describe(&self) -> String {
18-
match self {
19-
Enabled::Always(true) => "Yes".to_string(),
20-
Enabled::Always(false) => "No".to_string(),
21-
Enabled::OnPlatforms { platforms } => {
22-
format!("On platforms: {}", platforms.join(" | "))
23-
}
24-
}
25-
}
26-
}
27-
2814
#[derive(Serialize, Deserialize, Debug, Clone)]
2915
pub struct RepoEntry {
3016
pub name: String,

0 commit comments

Comments
 (0)