Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update document against target format check and add hints #5361

Merged
merged 2 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions bin/oli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,17 +72,17 @@ For different services, you could find the configuration keys in the correspondi
### Example: use `oli` to upload file to AWS S3

```text
$ oli cp ./update-ecs-loadbalancer.json s3://update-ecs-loadbalancer.json
$ oli ls s3://
$ oli cp ./update-ecs-loadbalancer.json s3:/update-ecs-loadbalancer.json
$ oli ls s3:/
fleet.png
update-ecs-loadbalancer.json
```

### Example: use `oli` copy file from S3 to R2

```text
$ oli cp s3://fleet.png r2://fleet.png
$ oli ls r2://
$ oli cp s3:/fleet.png r2:/fleet.png
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's more like a bug to me 😭

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I convinced myself this is by design 🙈

$ oli ls r2:/
fleet.png
```

Expand Down
1 change: 1 addition & 0 deletions bin/oli/src/commands/cat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use crate::params::config::ConfigParams;
pub struct CatCmd {
#[command(flatten)]
pub config_params: ConfigParams,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub target: String,
}
Expand Down
2 changes: 2 additions & 0 deletions bin/oli/src/commands/cp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ use crate::params::config::ConfigParams;
pub struct CopyCmd {
#[command(flatten)]
pub config_params: ConfigParams,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub source: String,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub destination: String,
/// Copy objects recursively.
Expand Down
1 change: 1 addition & 0 deletions bin/oli/src/commands/ls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ use crate::params::config::ConfigParams;
pub struct LsCmd {
#[command(flatten)]
pub config_params: ConfigParams,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub target: String,
/// List objects recursively.
Expand Down
1 change: 1 addition & 0 deletions bin/oli/src/commands/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ use crate::params::config::ConfigParams;
pub struct RmCmd {
#[command(flatten)]
pub config_params: ConfigParams,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub target: String,
/// Remove objects recursively.
Expand Down
1 change: 1 addition & 0 deletions bin/oli/src/commands/stat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use crate::params::config::ConfigParams;
pub struct StatCmd {
#[command(flatten)]
pub config_params: ConfigParams,
/// In the form of `<profile>:/<path>`.
#[arg()]
pub target: String,
}
Expand Down
4 changes: 2 additions & 2 deletions bin/oli/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl Config {

let location = Url::parse(s)?;
if location.has_host() {
Err(anyhow!("Host part in a location is not supported."))?;
Err(anyhow!("Host part in a location is not supported. Hint: are you typing `://` instead of `:/`?"))?;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems we are parsing the url in wrong.

}

let profile_name = location.scheme();
Expand Down Expand Up @@ -338,7 +338,7 @@ enable_virtual_host_style = "on"
let uri = "mys3://foo/1.txt";
let expected_msg = "Host part in a location is not supported.";
match cfg.parse_location(uri) {
Err(e) if e.to_string() == expected_msg => Ok(()),
Err(e) if e.to_string().contains(expected_msg) => Ok(()),
_ => Err(anyhow!(
"Getting an message \"{}\" is expected when parsing {}.",
expected_msg,
Expand Down