Skip to content

Commit 270f7d5

Browse files
committed
fix: refine codes
1 parent 2481fd7 commit 270f7d5

File tree

105 files changed

+1057
-1452
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+1057
-1452
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
"rust-analyzer.rustfmt.extraArgs": [
8181
"+nightly",
8282
"--config",
83-
"max_width=80,wrap_comments=true"
83+
"max_width=80,wrap_comments=true,wrap_comments=true,use_small_heuristics=Max,format_strings=true,style_edition=2021"
8484
],
8585
"rust-analyzer.showUnlinkedFileNotification": false,
8686
"search.exclude": {

core/src/ten_manager/src/cmd/cmd_create.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,10 @@ pub fn create_sub_cmd(args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
4646
)
4747
.arg(
4848
Arg::new("PACKAGE_NAME")
49-
.help("The name of the package with optional version requirement (e.g., [email protected])")
49+
.help(
50+
"The name of the package with optional version \
51+
requirement (e.g., [email protected])",
52+
)
5053
.required(true),
5154
)
5255
.arg(
@@ -74,8 +77,8 @@ pub fn create_sub_cmd(args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
7477
.long("template-data")
7578
.help(
7679
"The placeholders used within the template and their \
77-
corresponding values. The format is key-value pairs, e.g., \
78-
`--template-data key=value`",
80+
corresponding values. The format is key-value pairs, \
81+
e.g., `--template-data key=value`",
7982
)
8083
.value_name("KEY=VALUE")
8184
.action(ArgAction::Append),
@@ -96,9 +99,8 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<CreateCommand> {
9699
.cloned()
97100
.ok_or_else(|| anyhow!("Missing required argument: PACKAGE_NAME"))?;
98101

99-
let os = sub_cmd_args
100-
.get_one::<String>("OS")
101-
.and_then(|s| s.parse::<Os>().ok());
102+
let os =
103+
sub_cmd_args.get_one::<String>("OS").and_then(|s| s.parse::<Os>().ok());
102104

103105
let arch = sub_cmd_args
104106
.get_one::<String>("ARCH")
@@ -128,14 +130,13 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<CreateCommand> {
128130

129131
if cmd.template_data.contains_key("package_name") {
130132
return Err(anyhow!(
131-
"The 'package_name' is set via the command line as '{}', \
132-
and cannot be modified through '--template-data'.",
133+
"The 'package_name' is set via the command line as '{}', and \
134+
cannot be modified through '--template-data'.",
133135
cmd.pkg_name
134136
));
135137
}
136138

137-
cmd.template_data
138-
.insert("package_name".to_string(), cmd.pkg_name.clone());
139+
cmd.template_data.insert("package_name".to_string(), cmd.pkg_name.clone());
139140

140141
let template = sub_cmd_args
141142
.get_one::<String>("TEMPLATE")

core/src/ten_manager/src/cmd/cmd_delete.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,8 @@ pub fn create_sub_cmd(args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
4848
.help("The name of the package")
4949
.required(true),
5050
)
51-
.arg(
52-
Arg::new("VERSION")
53-
.help("The name of the package")
54-
.required(true),
55-
)
56-
.arg(
57-
Arg::new("HASH")
58-
.help("The hash of the package")
59-
.required(true),
60-
)
51+
.arg(Arg::new("VERSION").help("The name of the package").required(true))
52+
.arg(Arg::new("HASH").help("The hash of the package").required(true))
6153
}
6254

6355
pub fn parse_sub_cmd(

core/src/ten_manager/src/cmd/cmd_designer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ pub async fn execute_cmd(
102102

103103
out.normal_line(&format!(
104104
"{} Doesn't specify the base directory, use current working \
105-
directory instead: {}",
105+
directory instead: {}",
106106
Emoji("💡", "!"),
107107
&cwd
108108
));

core/src/ten_manager/src/cmd/cmd_fetch.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ pub fn create_sub_cmd(args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
4848
)
4949
.arg(
5050
Arg::new("PACKAGE_NAME")
51-
.help("The name of the package with optional version requirement (e.g., [email protected]")
51+
.help(
52+
"The name of the package with optional version \
53+
requirement (e.g., [email protected]",
54+
)
5255
.required(true),
5356
)
5457
.arg(

core/src/ten_manager/src/cmd/cmd_install.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ pub fn create_sub_cmd(args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
103103
)
104104
.arg(
105105
Arg::new("PACKAGE_NAME")
106-
.help("The name of the package with optional version requirement (e.g., [email protected])")
106+
.help(
107+
"The name of the package with optional version \
108+
requirement (e.g., [email protected])",
109+
)
107110
.required(false),
108111
)
109112
.arg(
@@ -194,7 +197,8 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<InstallCommand> {
194197

195198
if sub_cmd_args.get_one::<String>("PACKAGE_NAME").is_some() {
196199
return Err(anyhow::anyhow!(
197-
"PACKAGE_NAME is not required when a local path is specified."
200+
"PACKAGE_NAME is not required when a local path is \
201+
specified."
198202
));
199203
}
200204
} else {
@@ -531,9 +535,10 @@ pub async fn execute_cmd(
531535
|| local_version_str.contains(",")
532536
{
533537
return Err(anyhow!(
534-
"Invalid version requirement '{}' in local package manifest: contains forbidden characters (||, whitespace, or ,)",
535-
local_version_str
536-
));
538+
"Invalid version requirement '{}' in local package manifest: \
539+
contains forbidden characters (||, whitespace, or ,)",
540+
local_version_str
541+
));
537542
}
538543
let installing_pkg_version_req = VersionReq::parse(&local_version_str)?;
539544

@@ -590,8 +595,8 @@ pub async fn execute_cmd(
590595
}
591596

592597
out.normal_line(&format!(
593-
"{} Attempting to retrieve information about locked packages \
594-
from manifest-lock.json...",
598+
"{} Attempting to retrieve information about locked packages from \
599+
manifest-lock.json...",
595600
Emoji("📜", "")
596601
));
597602

@@ -609,9 +614,7 @@ from manifest-lock.json...",
609614
tman_config.clone(),
610615
&command_data.support,
611616
initial_pkgs_to_find_candidates,
612-
dep_relationship_from_cmd_line
613-
.as_ref()
614-
.map(|rel| &rel.dependency),
617+
dep_relationship_from_cmd_line.as_ref().map(|rel| &rel.dependency),
615618
&all_compatible_installed_pkgs,
616619
all_candidates,
617620
locked_pkgs.as_ref(),
@@ -681,8 +684,8 @@ from manifest-lock.json...",
681684
if out.is_interactive() {
682685
// "y" for continuing to install, "n" for stopping.
683686
let ans = Confirm::new(
684-
"Warning!!! Some local packages will be overwritten, \
685-
do you want to continue?",
687+
"Warning!!! Some local packages will be overwritten, do \
688+
you want to continue?",
686689
)
687690
.with_default(false)
688691
.prompt();

core/src/ten_manager/src/cmd/cmd_modify/cmd_modify_graph.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
5151
.short('m')
5252
.help(
5353
"The path=JsonString to modify in the selected graph. \
54-
E.g. .name=\"test\"",
54+
E.g. .name=\"test\"",
5555
)
5656
.required(true)
5757
.num_args(1),
@@ -68,10 +68,7 @@ pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
6868

6969
pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<ModifyGraphCommand> {
7070
let cmd = ModifyGraphCommand {
71-
app_dir: sub_cmd_args
72-
.get_one::<String>("APP_DIR")
73-
.unwrap()
74-
.to_string(),
71+
app_dir: sub_cmd_args.get_one::<String>("APP_DIR").unwrap().to_string(),
7572
predefined_graph_name: sub_cmd_args
7673
.get_one::<String>("PREDEFINED_GRAPH_NAME")
7774
.unwrap()

core/src/ten_manager/src/cmd/cmd_package.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
3939
.arg(
4040
Arg::new("GET_IDENTITY")
4141
.long("get-identity")
42-
.help("Output the package identity (type, name, version, hash) to stdout and exit")
42+
.help(
43+
"Output the package identity (type, name, version, hash) \
44+
to stdout and exit",
45+
)
4346
.action(clap::ArgAction::SetTrue)
4447
.hide(true)
4548
.required(false),
4649
)
4750
.after_help(
4851
"Switch to the base directory of the TEN package you want to \
49-
package, then simply run 'tman package' directly in that directory.",
52+
package, then simply run 'tman package' directly in that \
53+
directory.",
5054
)
5155
}
5256

@@ -55,10 +59,7 @@ pub fn parse_sub_cmd(
5559
) -> Result<crate::cmd::cmd_package::PackageCommand> {
5660
let output_path = sub_cmd_args.get_one::<String>("OUTPUT_PATH").cloned();
5761
let get_identity = sub_cmd_args.get_flag("GET_IDENTITY");
58-
Ok(crate::cmd::cmd_package::PackageCommand {
59-
output_path,
60-
get_identity,
61-
})
62+
Ok(crate::cmd::cmd_package::PackageCommand { output_path, get_identity })
6263
}
6364

6465
pub async fn execute_cmd(

core/src/ten_manager/src/cmd/cmd_publish.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ use crate::registry::upload_package;
2828
pub struct PublishCommand {}
2929

3030
pub fn create_sub_cmd(_args_cfg: &crate::cmd_line::ArgsCfg) -> Command {
31-
Command::new("publish")
32-
.about("Publish a package")
33-
.after_help(
34-
"Switch to the base directory of the TEN package you want to \
35-
publish, then simply run 'tman publish' directly in that directory.",
36-
)
31+
Command::new("publish").about("Publish a package").after_help(
32+
"Switch to the base directory of the TEN package you want to publish, \
33+
then simply run 'tman publish' directly in that directory.",
34+
)
3735
}
3836

3937
pub fn parse_sub_cmd(

core/src/ten_manager/src/cmd/cmd_run.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,7 @@ pub fn parse_sub_cmd(sub_cmd_args: &ArgMatches) -> Result<RunCommand> {
5858
.map(|vals| vals.map(|s| s.to_string()).collect())
5959
.unwrap_or_default();
6060

61-
Ok(RunCommand {
62-
script_name,
63-
extra_args,
64-
})
61+
Ok(RunCommand { script_name, extra_args })
6562
}
6663

6764
pub async fn execute_cmd(
@@ -102,7 +99,7 @@ pub async fn execute_cmd(
10299
return Err(anyhow!(
103100
"No 'scripts' field found in {}",
104101
manifest_path.display()
105-
))
102+
));
106103
}
107104
};
108105

@@ -129,7 +126,7 @@ pub async fn execute_cmd(
129126
"Script '{}' not found in '{}'",
130127
&cmd.script_name,
131128
SCRIPTS
132-
))
129+
));
133130
}
134131
};
135132

0 commit comments

Comments
 (0)