@repokit/core 2.0.7 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +113 -7
- package/Cargo.toml +3 -2
- package/README.md +45 -0
- package/dist/RepoKitConfig.d.mts +4 -1
- package/dist/RepoKitConfig.mjs +3 -1
- package/dist/RepoKitTheme.d.mts +47 -0
- package/dist/RepoKitTheme.mjs +45 -0
- package/dist/index.d.mts +4 -3
- package/dist/index.mjs +2 -1
- package/dist/types.d.mts +18 -5
- package/externals/RepoKitConfig.ts +10 -2
- package/externals/RepoKitTheme.ts +44 -0
- package/externals/index.ts +1 -0
- package/externals/types.ts +25 -4
- package/installation/install.sh +9 -3
- package/internals/argv/argv.rs +133 -0
- package/internals/argv/mod.rs +1 -0
- package/internals/configuration/configuration.rs +2 -2
- package/internals/internal_commands/help.rs +57 -45
- package/internals/internal_commands/internal_registry.rs +5 -4
- package/internals/internal_commands/list_commands.rs +3 -3
- package/internals/internal_commands/list_owners.rs +10 -10
- package/internals/internal_commands/list_themes.rs +113 -0
- package/internals/internal_commands/locate_command.rs +8 -2
- package/internals/internal_commands/mod.rs +1 -0
- package/internals/internal_commands/onboarder.rs +10 -4
- package/internals/internal_commands/register_command.rs +3 -3
- package/internals/internal_commands/search_commands.rs +3 -3
- package/internals/internal_commands/upgrade_repokit.rs +5 -1
- package/internals/internal_filesystem/internal_filesystem.rs +124 -3
- package/internals/logger/logger.rs +44 -56
- package/internals/main.rs +2 -0
- package/internals/repokit/interfaces.rs +3 -0
- package/internals/repokit/repokit.rs +9 -6
- package/internals/themes/built_in_themes/mod.rs +3 -0
- package/internals/themes/built_in_themes/money.rs +41 -0
- package/internals/themes/built_in_themes/seeing_red.rs +41 -0
- package/internals/themes/built_in_themes/the_blues.rs +41 -0
- package/internals/themes/mod.rs +5 -0
- package/internals/themes/theme.rs +108 -0
- package/internals/themes/theme_colors.rs +36 -0
- package/internals/themes/theme_inputs.rs +34 -0
- package/internals/themes/theme_registry.rs +102 -0
- package/internals/validations/command_validations.rs +8 -8
- package/media/seeing-red.webp +0 -0
- package/package.json +5 -4
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
use std::{collections::HashMap, env};
|
|
2
|
+
|
|
3
|
+
use crate::logger::logger::Logger;
|
|
4
|
+
|
|
5
|
+
#[derive(Clone)]
|
|
6
|
+
pub enum ArgvType {
|
|
7
|
+
String,
|
|
8
|
+
Boolean,
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
#[derive(Clone)]
|
|
12
|
+
pub struct ArgvOption {
|
|
13
|
+
pub value_type: ArgvType,
|
|
14
|
+
pub short: Option<String>,
|
|
15
|
+
pub name: String,
|
|
16
|
+
pub multiple: Option<bool>,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
pub struct Argv {
|
|
20
|
+
pub values: HashMap<String, Vec<String>>,
|
|
21
|
+
lookup_table: HashMap<String, ArgvOption>,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
impl Argv {
|
|
25
|
+
pub fn new(schema: Vec<ArgvOption>, args: Option<Vec<String>>) -> Argv {
|
|
26
|
+
let mut argv = Argv {
|
|
27
|
+
values: HashMap::new(),
|
|
28
|
+
lookup_table: Argv::build_option_table(&schema),
|
|
29
|
+
};
|
|
30
|
+
argv.parse(args);
|
|
31
|
+
argv
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
pub fn has(&self, key: &str) -> bool {
|
|
35
|
+
let fallback_bucket = Vec::new();
|
|
36
|
+
let values = self.values.get(key).unwrap_or(&fallback_bucket);
|
|
37
|
+
!values.is_empty()
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
pub fn get_first(&self, key: &str) -> String {
|
|
41
|
+
let fallback_bucket = Vec::new();
|
|
42
|
+
let values = self.values.get(key).unwrap_or(&fallback_bucket);
|
|
43
|
+
if values.is_empty() {
|
|
44
|
+
return "".to_string();
|
|
45
|
+
}
|
|
46
|
+
values[0].clone()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
pub fn get_all(&mut self, key: &str) -> &mut Vec<String> {
|
|
50
|
+
self.values.entry(key.to_string()).or_default()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
fn parse(&mut self, argv: Option<Vec<String>>) {
|
|
54
|
+
let args = argv.unwrap_or(env::args().collect());
|
|
55
|
+
let mut pointer = 0;
|
|
56
|
+
let length = args.len();
|
|
57
|
+
while pointer < length {
|
|
58
|
+
let arg = &args[pointer];
|
|
59
|
+
if self.lookup_table.contains_key(arg) {
|
|
60
|
+
let schema = self.lookup_table.get(arg).expect("arg exists");
|
|
61
|
+
let values = self.values.entry(schema.name.to_string()).or_default();
|
|
62
|
+
match schema.value_type {
|
|
63
|
+
ArgvType::Boolean => {
|
|
64
|
+
values.push("1".to_string());
|
|
65
|
+
pointer += 1;
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
ArgvType::String => {
|
|
69
|
+
let mut current = pointer + 1;
|
|
70
|
+
while current < length {
|
|
71
|
+
let value = &args[current];
|
|
72
|
+
if self.lookup_table.contains_key(value) {
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
if values.len() == 1
|
|
76
|
+
&& (schema.multiple.is_none()
|
|
77
|
+
|| schema.multiple.is_some_and(|v| !v))
|
|
78
|
+
{
|
|
79
|
+
Logger::error(
|
|
80
|
+
format!(
|
|
81
|
+
"Recived more than one value for the option {}",
|
|
82
|
+
Logger::with_theme(|theme| theme.highlight(&schema.name))
|
|
83
|
+
)
|
|
84
|
+
.as_str(),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
values.push(value.to_string());
|
|
88
|
+
current += 1;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
pointer += 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
fn build_option_table(options: &Vec<ArgvOption>) -> HashMap<String, ArgvOption> {
|
|
98
|
+
let mut table: HashMap<String, ArgvOption> = HashMap::new();
|
|
99
|
+
for option in options {
|
|
100
|
+
if option.name.len() < 2 {
|
|
101
|
+
Logger::exit_with_error("Option names must be at least 2 characters");
|
|
102
|
+
}
|
|
103
|
+
let first_char = option
|
|
104
|
+
.name
|
|
105
|
+
.chars()
|
|
106
|
+
.next()
|
|
107
|
+
.expect("already checked for emptiness")
|
|
108
|
+
.to_string();
|
|
109
|
+
let short_flag = option.short.as_ref().unwrap_or(&first_char);
|
|
110
|
+
let flags = [format!("--{}", option.name), format!("-{}", short_flag)];
|
|
111
|
+
for flag in flags {
|
|
112
|
+
if table.contains_key(&flag) {
|
|
113
|
+
Logger::error(
|
|
114
|
+
format!(
|
|
115
|
+
"I encountered the flag {} more than once.",
|
|
116
|
+
Logger::with_theme(|theme| theme.highlight(&flag)),
|
|
117
|
+
)
|
|
118
|
+
.as_str(),
|
|
119
|
+
);
|
|
120
|
+
Logger::error(
|
|
121
|
+
format!(
|
|
122
|
+
"Short flags will default to the first letter of the option's name. If two options begin with the same letter, please specify the {} option for one of them.",
|
|
123
|
+
Logger::with_theme(|theme| theme.highlight("short")),
|
|
124
|
+
)
|
|
125
|
+
.as_str(),
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
table.insert(flag, option.clone());
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
table
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
pub mod argv;
|
|
@@ -15,7 +15,7 @@ impl Configuration {
|
|
|
15
15
|
Logger::info(
|
|
16
16
|
format!(
|
|
17
17
|
"I found a Repokit configuration without an exported {} instance",
|
|
18
|
-
Logger::
|
|
18
|
+
Logger::with_theme(|theme| theme.highlight("RepokitConfig"))
|
|
19
19
|
)
|
|
20
20
|
.as_str(),
|
|
21
21
|
);
|
|
@@ -29,7 +29,7 @@ impl Configuration {
|
|
|
29
29
|
Logger::info(
|
|
30
30
|
format!(
|
|
31
31
|
"Please fill out this file with your desired settings. Then run {}",
|
|
32
|
-
Logger::
|
|
32
|
+
Logger::with_theme(|theme| theme.highlight("repokit onboard"))
|
|
33
33
|
)
|
|
34
34
|
.as_str(),
|
|
35
35
|
);
|
|
@@ -25,52 +25,62 @@ impl Help {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
pub fn log_internal_command(command: &InternalExecutableDefinition) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
Logger::with_theme(|theme| {
|
|
29
|
+
println!(
|
|
30
|
+
"{}{} {}",
|
|
31
|
+
Logger::indent(Some(3)),
|
|
32
|
+
theme.command(&command.name),
|
|
33
|
+
theme.description(&command.description),
|
|
34
|
+
);
|
|
35
|
+
});
|
|
34
36
|
Help::log_args(&command.args, None);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
pub fn log_root_command(command: &RootCommand) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
Logger::with_theme(|theme| {
|
|
41
|
+
println!(
|
|
42
|
+
"{}{} {}",
|
|
43
|
+
Logger::indent(Some(3)),
|
|
44
|
+
theme.command(&command.name),
|
|
45
|
+
theme.description(&command.description),
|
|
46
|
+
);
|
|
47
|
+
});
|
|
44
48
|
Help::log_args(&command.args, None)
|
|
45
49
|
}
|
|
46
50
|
|
|
47
51
|
pub fn log_external_command(command: &RepoKitCommand) {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
Logger::with_theme(|theme| {
|
|
53
|
+
println!(
|
|
54
|
+
"{}{} {}",
|
|
55
|
+
Logger::indent(Some(3)),
|
|
56
|
+
theme.command(&command.name),
|
|
57
|
+
theme.description(&command.description),
|
|
58
|
+
);
|
|
59
|
+
});
|
|
54
60
|
println!();
|
|
55
61
|
Help::log_external_subcommands(&command.commands, 6);
|
|
56
62
|
if !command.owner.is_empty() {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
+
Logger::with_theme(|theme| {
|
|
64
|
+
println!(
|
|
65
|
+
"\n{}{}{}",
|
|
66
|
+
Logger::indent(Some(9)),
|
|
67
|
+
theme.description("Owned by: "),
|
|
68
|
+
Logger::cyan(&command.owner),
|
|
69
|
+
);
|
|
70
|
+
});
|
|
63
71
|
}
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
pub fn log_external_subcommands(map: &HashMap<String, CommandDefinition>, indentation: i32) {
|
|
67
75
|
for (name, command) in map {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
Logger::with_theme(|theme| {
|
|
77
|
+
println!(
|
|
78
|
+
"{}{}: {}",
|
|
79
|
+
Logger::indent(Some(indentation)),
|
|
80
|
+
theme.sub_command(name),
|
|
81
|
+
theme.description(&command.description),
|
|
82
|
+
);
|
|
83
|
+
});
|
|
74
84
|
Help::log_args(&command.args, Some(indentation + 3));
|
|
75
85
|
}
|
|
76
86
|
}
|
|
@@ -91,13 +101,13 @@ impl Help {
|
|
|
91
101
|
if root_commands.is_empty() {
|
|
92
102
|
return;
|
|
93
103
|
}
|
|
94
|
-
let sorted_commands = Help::sort_root_commands(root_commands);
|
|
95
104
|
Logger::info("Project Level Commands:");
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
Logger::with_surrounding_space(|| {
|
|
106
|
+
let sorted_commands = Help::sort_root_commands(root_commands);
|
|
107
|
+
for command in sorted_commands {
|
|
108
|
+
Help::log_root_command(&command);
|
|
109
|
+
}
|
|
110
|
+
});
|
|
101
111
|
}
|
|
102
112
|
|
|
103
113
|
pub fn log_external_commands(externals: &HashMap<String, RepoKitCommand>) {
|
|
@@ -114,16 +124,18 @@ impl Help {
|
|
|
114
124
|
}
|
|
115
125
|
|
|
116
126
|
fn log_args(map: &Option<HashMap<String, String>>, indentation: Option<i32>) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
Logger::with_theme(|theme| {
|
|
128
|
+
if let Some(args) = map {
|
|
129
|
+
for (name, description) in args {
|
|
130
|
+
println!(
|
|
131
|
+
"{}{} {}",
|
|
132
|
+
Logger::indent(Some(indentation.unwrap_or(6))),
|
|
133
|
+
theme.arg(name),
|
|
134
|
+
theme.description(description)
|
|
135
|
+
);
|
|
136
|
+
}
|
|
125
137
|
}
|
|
126
|
-
}
|
|
138
|
+
});
|
|
127
139
|
}
|
|
128
140
|
|
|
129
141
|
fn sort_internal(
|
|
@@ -5,9 +5,9 @@ use crate::{
|
|
|
5
5
|
intenal_executable::InternalExecutable, internal_executable_definition::RepoKitScope,
|
|
6
6
|
},
|
|
7
7
|
internal_commands::{
|
|
8
|
-
list_commands::ListCommands, list_owners::ListOwners,
|
|
9
|
-
onboarder::Onboarder, register_command::RegisterCommand,
|
|
10
|
-
upgrade_repokit::UpgradeRepoKit,
|
|
8
|
+
list_commands::ListCommands, list_owners::ListOwners, list_themes::ListThemes,
|
|
9
|
+
locate_command::LocateCommand, onboarder::Onboarder, register_command::RegisterCommand,
|
|
10
|
+
search_commands::SearchCommands, upgrade_repokit::UpgradeRepoKit,
|
|
11
11
|
},
|
|
12
12
|
};
|
|
13
13
|
|
|
@@ -23,7 +23,7 @@ impl InternalRegistry {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
pub fn get_all(&self) -> HashMap<String, Box<dyn InternalExecutable>> {
|
|
26
|
-
let internals: [Box<dyn InternalExecutable>;
|
|
26
|
+
let internals: [Box<dyn InternalExecutable>; 8] = [
|
|
27
27
|
Box::new(Onboarder::new(&self.scope)),
|
|
28
28
|
Box::new(ListCommands::new(&self.scope)),
|
|
29
29
|
Box::new(SearchCommands::new(&self.scope)),
|
|
@@ -31,6 +31,7 @@ impl InternalRegistry {
|
|
|
31
31
|
Box::new(LocateCommand::new(&self.scope)),
|
|
32
32
|
Box::new(RegisterCommand::new(&self.scope)),
|
|
33
33
|
Box::new(UpgradeRepoKit::new(&self.scope)),
|
|
34
|
+
Box::new(ListThemes::new(&self.scope)),
|
|
34
35
|
];
|
|
35
36
|
HashMap::from(internals.map(|x| (x.get_definition().name.to_string(), x)))
|
|
36
37
|
}
|
|
@@ -31,7 +31,7 @@ impl ListCommands {
|
|
|
31
31
|
"<scope>",
|
|
32
32
|
format!(
|
|
33
33
|
"The scope of the commands you wish to list. Specify one of {}",
|
|
34
|
-
Logger::
|
|
34
|
+
Logger::with_theme(|theme| theme.highlight(SCOPES.join(" | ").as_str()))
|
|
35
35
|
)
|
|
36
36
|
.as_str(),
|
|
37
37
|
)],
|
|
@@ -48,7 +48,7 @@ impl ListCommands {
|
|
|
48
48
|
Logger::exit_with_info(
|
|
49
49
|
format!(
|
|
50
50
|
"Please specify a scope to list the commands of. Select one of {}",
|
|
51
|
-
Logger::
|
|
51
|
+
Logger::with_theme(|theme| theme.highlight(SCOPES.join(" | ").as_str()))
|
|
52
52
|
)
|
|
53
53
|
.as_str(),
|
|
54
54
|
);
|
|
@@ -88,7 +88,7 @@ impl InternalExecutable for ListCommands {
|
|
|
88
88
|
Logger::exit_with_info(
|
|
89
89
|
format!(
|
|
90
90
|
"I could not find any commands matching {}",
|
|
91
|
-
Logger::
|
|
91
|
+
Logger::with_theme(|theme| theme.highlight(&full_query))
|
|
92
92
|
)
|
|
93
93
|
.as_str(),
|
|
94
94
|
);
|
|
@@ -51,17 +51,17 @@ impl InternalExecutable for ListOwners {
|
|
|
51
51
|
if owners.is_empty() {
|
|
52
52
|
return Logger::exit_with_info("No owners found");
|
|
53
53
|
}
|
|
54
|
-
println!();
|
|
55
54
|
let mut list: Vec<String> = owners.into_iter().collect();
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
55
|
+
Logger::with_surrounding_space(|| {
|
|
56
|
+
sort_str_slice(&mut list);
|
|
57
|
+
for (index, owner) in list.iter().enumerate() {
|
|
58
|
+
println!(
|
|
59
|
+
"{}{}",
|
|
60
|
+
Logger::indent(None),
|
|
61
|
+
Logger::cyan(format!("{}. {}", index + 1, &owner).as_str()),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
fn help(&self) {
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
use std::collections::HashMap;
|
|
2
|
+
|
|
3
|
+
use alphanumeric_sort::sort_str_slice;
|
|
4
|
+
use colored::Colorize;
|
|
5
|
+
|
|
6
|
+
use crate::{
|
|
7
|
+
argv::argv::{Argv, ArgvOption, ArgvType},
|
|
8
|
+
executables::{
|
|
9
|
+
intenal_executable::InternalExecutable,
|
|
10
|
+
internal_executable_definition::{
|
|
11
|
+
InternalExecutableDefinition, InternalExecutableDefinitionInput, RepoKitScope,
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
internal_commands::help::Help,
|
|
15
|
+
logger::logger::Logger,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
pub struct ListThemes {
|
|
19
|
+
pub scope: RepoKitScope,
|
|
20
|
+
pub definition: InternalExecutableDefinition,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
impl ListThemes {
|
|
24
|
+
pub fn new(scope: &RepoKitScope) -> ListThemes {
|
|
25
|
+
ListThemes {
|
|
26
|
+
scope: scope.clone(),
|
|
27
|
+
definition: InternalExecutableDefinition::define(InternalExecutableDefinitionInput {
|
|
28
|
+
name: "themes",
|
|
29
|
+
description: "Lists your repositories available themes",
|
|
30
|
+
args: [(
|
|
31
|
+
"(--set | -s)",
|
|
32
|
+
"An optional flag allowing you to set your theme",
|
|
33
|
+
)],
|
|
34
|
+
}),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
fn list_themes(&self) {
|
|
39
|
+
Logger::info("Listing available themes");
|
|
40
|
+
let themes = Logger::with_registry(|registry| registry.themes.clone());
|
|
41
|
+
let current_theme = Logger::with_theme(|theme| theme.name.clone());
|
|
42
|
+
let mut keys: Vec<&String> = themes.keys().collect();
|
|
43
|
+
sort_str_slice(&mut keys);
|
|
44
|
+
Logger::with_surrounding_space(|| {
|
|
45
|
+
let mut pointer = 1;
|
|
46
|
+
for name in &keys {
|
|
47
|
+
let mut post_fix = "";
|
|
48
|
+
let is_active_theme = name.as_str() == current_theme;
|
|
49
|
+
if is_active_theme {
|
|
50
|
+
post_fix = " <--- selected";
|
|
51
|
+
}
|
|
52
|
+
println!(
|
|
53
|
+
"{}{}{}",
|
|
54
|
+
Logger::indent(None),
|
|
55
|
+
Logger::with_theme(|theme| {
|
|
56
|
+
let name_text = if is_active_theme {
|
|
57
|
+
theme.highlight(name).bold()
|
|
58
|
+
} else {
|
|
59
|
+
theme.highlight(name)
|
|
60
|
+
};
|
|
61
|
+
format!("{}. {}", pointer.to_string().as_str(), name_text)
|
|
62
|
+
}),
|
|
63
|
+
post_fix
|
|
64
|
+
);
|
|
65
|
+
pointer += 1;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
impl InternalExecutable for ListThemes {
|
|
72
|
+
fn run(&self, args: Vec<String>, _: &HashMap<String, Box<dyn InternalExecutable>>) {
|
|
73
|
+
let argv = Argv::new(
|
|
74
|
+
vec![ArgvOption {
|
|
75
|
+
name: "set".to_string(),
|
|
76
|
+
value_type: ArgvType::String,
|
|
77
|
+
short: None,
|
|
78
|
+
multiple: None,
|
|
79
|
+
}],
|
|
80
|
+
Some(args),
|
|
81
|
+
);
|
|
82
|
+
if !argv.has("set") {
|
|
83
|
+
return self.list_themes();
|
|
84
|
+
}
|
|
85
|
+
let desired_theme = argv.get_first("set");
|
|
86
|
+
if Logger::with_registry(|registry| !registry.has(&desired_theme)) {
|
|
87
|
+
Logger::error(
|
|
88
|
+
format!(
|
|
89
|
+
"I'm not aware of a theme named {}",
|
|
90
|
+
Logger::with_theme(|theme| theme.highlight(&desired_theme))
|
|
91
|
+
)
|
|
92
|
+
.as_str(),
|
|
93
|
+
);
|
|
94
|
+
return self.list_themes();
|
|
95
|
+
}
|
|
96
|
+
Logger::with_registry(|mut registry| registry.set_theme(&self.scope.root, &desired_theme));
|
|
97
|
+
Logger::info(
|
|
98
|
+
format!(
|
|
99
|
+
"Your theme has been set to {}",
|
|
100
|
+
Logger::with_theme(|theme| theme.highlight(&desired_theme))
|
|
101
|
+
)
|
|
102
|
+
.as_str(),
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
fn help(&self) {
|
|
107
|
+
Help::log_internal_command(&self.definition);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
fn get_definition(&self) -> &InternalExecutableDefinition {
|
|
111
|
+
&self.definition
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -54,13 +54,19 @@ impl InternalExecutable for LocateCommand {
|
|
|
54
54
|
Logger::exit_with_info("Please specify a command to locate");
|
|
55
55
|
}
|
|
56
56
|
let command = &args[0];
|
|
57
|
-
Logger::info(
|
|
57
|
+
Logger::info(
|
|
58
|
+
format!(
|
|
59
|
+
"Locating a command named {}",
|
|
60
|
+
Logger::with_theme(|theme| theme.highlight(command))
|
|
61
|
+
)
|
|
62
|
+
.as_str(),
|
|
63
|
+
);
|
|
58
64
|
self.search_externals(command);
|
|
59
65
|
self.search_root(command);
|
|
60
66
|
Logger::exit_with_error(
|
|
61
67
|
format!(
|
|
62
68
|
"I could not find a command named {}",
|
|
63
|
-
Logger::
|
|
69
|
+
Logger::with_theme(|theme| theme.highlight(command))
|
|
64
70
|
)
|
|
65
71
|
.as_str(),
|
|
66
72
|
);
|
|
@@ -31,12 +31,18 @@ impl Onboarder {
|
|
|
31
31
|
|
|
32
32
|
impl InternalExecutable for Onboarder {
|
|
33
33
|
fn run(&self, _: Vec<String>, _: &HashMap<String, Box<dyn InternalExecutable>>) {
|
|
34
|
-
Logger::info(
|
|
34
|
+
Logger::info(
|
|
35
|
+
format!(
|
|
36
|
+
"Welcome to {}",
|
|
37
|
+
Logger::with_theme(|theme| theme.highlight("Repokit"))
|
|
38
|
+
)
|
|
39
|
+
.as_str(),
|
|
40
|
+
);
|
|
35
41
|
Logger::info(
|
|
36
42
|
"Repokit is a tool designed to self-document and publish developer facing workflows in a single CLI",
|
|
37
43
|
);
|
|
38
44
|
Logger::info(
|
|
39
|
-
format!("As you develop new features in your codebase, you can publish commands, API's, and tools to the {} CLI by running", Logger::
|
|
45
|
+
format!("As you develop new features in your codebase, you can publish commands, API's, and tools to the {} CLI by running", Logger::with_theme(|theme|theme.highlight("Repokit"))).as_str()
|
|
40
46
|
);
|
|
41
47
|
Logger::log_file_path("repokit register ./path/to/your-feature");
|
|
42
48
|
Logger::info(
|
|
@@ -45,12 +51,12 @@ impl InternalExecutable for Onboarder {
|
|
|
45
51
|
Logger::info(
|
|
46
52
|
format!(
|
|
47
53
|
"The {} CLI will automatically detect these files and add them to its toolchain",
|
|
48
|
-
Logger::
|
|
54
|
+
Logger::with_theme(|theme| theme.highlight("Repokit"))
|
|
49
55
|
)
|
|
50
56
|
.as_str(),
|
|
51
57
|
);
|
|
52
58
|
Logger::info(
|
|
53
|
-
format!("As your codebase grows, your {} CLI will continue to track all of the published workflows created by your team", Logger::
|
|
59
|
+
format!("As your codebase grows, your {} CLI will continue to track all of the published workflows created by your team", Logger::with_theme(|theme|theme.highlight("Repokit"))).as_str()
|
|
54
60
|
);
|
|
55
61
|
Logger::space_around("It's your living source of knowledge and documentation");
|
|
56
62
|
}
|
|
@@ -50,7 +50,7 @@ impl RegisterCommand {
|
|
|
50
50
|
Logger::info(
|
|
51
51
|
format!(
|
|
52
52
|
"Creating the path {} in your file system",
|
|
53
|
-
Logger::
|
|
53
|
+
Logger::with_theme(|theme| theme.highlight(path_arg.as_str()))
|
|
54
54
|
)
|
|
55
55
|
.as_str(),
|
|
56
56
|
);
|
|
@@ -64,13 +64,13 @@ impl RegisterCommand {
|
|
|
64
64
|
Logger::error(
|
|
65
65
|
format!(
|
|
66
66
|
"A {} file already exists in this directory",
|
|
67
|
-
Logger::
|
|
67
|
+
Logger::with_theme(|theme| theme.highlight("Commands.ts"))
|
|
68
68
|
)
|
|
69
69
|
.as_str(),
|
|
70
70
|
);
|
|
71
71
|
Logger::info(format!(
|
|
72
72
|
"You can append additional commands to the existing {} instance or export another one",
|
|
73
|
-
Logger::
|
|
73
|
+
Logger::with_theme(|theme| theme.highlight("RepoKitCommand"))
|
|
74
74
|
).as_str());
|
|
75
75
|
process::exit(0);
|
|
76
76
|
}
|
|
@@ -98,7 +98,7 @@ impl SearchCommands {
|
|
|
98
98
|
Logger::info(
|
|
99
99
|
format!(
|
|
100
100
|
"Matched {} command{} in your repokit config",
|
|
101
|
-
Logger::
|
|
101
|
+
Logger::with_theme(|theme| theme.highlight(total.to_string().as_str())),
|
|
102
102
|
plural_appendage,
|
|
103
103
|
)
|
|
104
104
|
.as_str(),
|
|
@@ -124,7 +124,7 @@ impl SearchCommands {
|
|
|
124
124
|
Logger::info(
|
|
125
125
|
format!(
|
|
126
126
|
"Matched {} internal command{}",
|
|
127
|
-
Logger::
|
|
127
|
+
Logger::with_theme(|theme| theme.highlight(total.to_string().as_str())),
|
|
128
128
|
plural_appendage,
|
|
129
129
|
)
|
|
130
130
|
.as_str(),
|
|
@@ -140,7 +140,7 @@ impl SearchCommands {
|
|
|
140
140
|
Logger::info(
|
|
141
141
|
format!(
|
|
142
142
|
"Matched {} registered command{}",
|
|
143
|
-
Logger::
|
|
143
|
+
Logger::with_theme(|theme| theme.highlight(total.to_string().as_str())),
|
|
144
144
|
plural_appendage,
|
|
145
145
|
)
|
|
146
146
|
.as_str(),
|
|
@@ -41,7 +41,11 @@ impl UpgradeRepoKit {
|
|
|
41
41
|
let path = Path::new(&self.scope.root).join(lock_file).normalize();
|
|
42
42
|
if path.exists() && path.is_file() {
|
|
43
43
|
Logger::info(
|
|
44
|
-
format!(
|
|
44
|
+
format!(
|
|
45
|
+
"Detected {} installation",
|
|
46
|
+
Logger::with_theme(|theme| theme.highlight(manager))
|
|
47
|
+
)
|
|
48
|
+
.as_str(),
|
|
45
49
|
);
|
|
46
50
|
return command_prefix;
|
|
47
51
|
}
|