You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by "Xuanwo (via GitHub)" <gi...@apache.org> on 2023/03/27 14:50:36 UTC

[GitHub] [incubator-opendal] Xuanwo commented on a diff in pull request #1778: feat(oli): implement `oli stat`

Xuanwo commented on code in PR #1778:
URL: https://github.com/apache/incubator-opendal/pull/1778#discussion_r1149368354


##########
bin/oli/src/commands/stat.rs:
##########
@@ -0,0 +1,59 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use std::path::PathBuf;
+
+use anyhow::{anyhow, Result};
+use clap::{Arg, ArgMatches, Command};
+
+use crate::config::Config;
+
+pub async fn main(args: &ArgMatches) -> Result<()> {
+    let config_path = args
+        .get_one::<PathBuf>("config")
+        .ok_or_else(|| anyhow!("missing config path"))?;
+    let cfg = Config::load(config_path)?;
+
+    let target = args
+        .get_one::<String>("target")
+        .ok_or_else(|| anyhow!("missing target"))?;
+    let (op, path) = cfg.parse_location(target)?;
+
+    let meta = op.stat(&path).await?;
+    println!("Path: {path}");
+    let size = meta.content_length();
+    println!("Size: {size}");
+    if let Some(etag) = meta.etag() {
+        println!("Etag: {etag}");
+    }
+    let file_type = meta.mode();
+    println!("Type: {file_type}");
+    if let Some(content_type) = meta.content_type() {
+        println!("Content-Type: {content_type}");

Review Comment:
   Mostly LGTM! But I will prefer to keep all entry style consistent. How about using ContentType here?
   
   Or, we can use
   
   ```
   path: abc
   size: 1234
   content-type: xxx
   last-modified: yyy
   ```
   
   ?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@opendal.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org