ソースを参照

Improve archive name derivation, disable boolean env vars, hide env values

timvisee 7 年 前
コミット
a644792259

+ 3 - 1
REQUIREMENTS.md

@@ -12,10 +12,12 @@ toolchain.
 
 ## Environment variables
 - `FFSEND_HOST`: upload host (string)
+- `FFSEND_HISTORY`: history file path (string)
+
+Temporarily disabled:
 - `FFSEND_FORCE`: upload host (present/boolean)
 - `FFSEND_NO_INTERACT`: upload host (present/boolean)
 - `FFSEND_YES`: upload host (present/boolean)
-- `FFSEND_HISTORY`: history file path (string)
 - `FFSEND_INCOGNITO`: incognito mode (present/boolean)
 - `FFSEND_OPEN`: open an uploaded file (present/boolean)
 - `FFSEND_ARCHIVE`: enable file archival (present/boolean)

+ 1 - 0
ROADMAP.md

@@ -30,6 +30,7 @@ Features:
 - Allow piping input/output files
 - Allow hiding the progress bar, and/or showing simple progress (with `-q`)
 - Implement a quiet `-q` mode
+- Update all dependencies
 - Check all TODOs, solve them when possible
 
 # Future releases

+ 5 - 3
cli/src/action/upload.rs

@@ -159,8 +159,10 @@ impl<'a> Upload<'a> {
                     if file_name.is_none() {
                         // TODO: use canonical path here
                         file_name = Some(
-                            path.file_name()
-                                .ok_or(ArchiveError::FileName)?
+                            path.canonicalize()
+                                .map_err(|err| ArchiveError::FileName(Some(err)))?
+                                .file_name()
+                                .ok_or(ArchiveError::FileName(None))?
                                 .to_str()
                                 .map(|s| s.to_owned())
                                 .expect("failed to create string from file name")
@@ -273,7 +275,7 @@ pub enum ArchiveError {
 
     /// Failed to infer a file name for the archive.
     #[fail(display = "failed to infer a file name for the archive")]
-    FileName,
+    FileName(Option<IoError>),
 
     /// Failed to add a file or directory to the archive.
     #[fail(display = "failed to add file to the archive")]

+ 1 - 0
cli/src/cmd/arg/host.rs

@@ -22,6 +22,7 @@ impl CmdArg for ArgHost {
             .value_name("URL")
             .default_value(SEND_DEFAULT_HOST)
             .env("FFSEND_HOST")
+            .hide_env_values(true)
             .help("The remote host to upload to")
     }
 }

+ 2 - 5
cli/src/cmd/handler.rs

@@ -62,21 +62,18 @@ impl<'a: 'b, 'b> Handler<'a> {
                 .long("force")
                 .short("f")
                 .global(true)
-                .env("FFSEND_FORCE")
                 .help("Force the action, ignore warnings"))
             .arg(Arg::with_name("no-interact")
                 .long("no-interact")
                 .short("I")
                 .alias("no-interactive")
                 .global(true)
-                .env("FFSEND_NO_INTERACT")
                 .help("Not interactive, do not prompt"))
             .arg(Arg::with_name("yes")
                 .long("yes")
                 .short("y")
                 .alias("assume-yes")
                 .global(true)
-                .env("FFSEND_YES")
                 .help("Assume yes for prompts"))
             .subcommand(CmdDebug::build())
             .subcommand(CmdDelete::build())
@@ -96,8 +93,9 @@ impl<'a: 'b, 'b> Handler<'a> {
                 .global(true)
                 .help("Use the specified history file")
                 .default_value(&DEFAULT_HISTORY_FILE)
+                .hide_default_value(true)
                 .env("FFSEND_HISTORY")
-                .hide_default_value(true))
+                .hide_env_values(true))
             .arg(Arg::with_name("incognito")
                 .long("incognito")
                 .short("i")
@@ -105,7 +103,6 @@ impl<'a: 'b, 'b> Handler<'a> {
                 .alias("private")
                 .alias("priv")
                 .global(true)
-                .env("FFSEND_INCOGNITO")
                 .help("Don't update local history for actions"))
             .subcommand(CmdHistory::build());
 

+ 0 - 3
cli/src/cmd/subcmd/upload.rs

@@ -35,7 +35,6 @@ impl CmdUpload {
             .arg(Arg::with_name("open")
                 .long("open")
                 .short("o")
-                .env("FFSEND_OPEN")
                 .help("Open the share link in your browser"));
 
         // Optional archive support
@@ -44,7 +43,6 @@ impl CmdUpload {
                 .long("archive")
                 .short("a")
                 .alias("arch")
-                .env("FFSEND_ARCHIVE")
                 .help("Package the file as an archive"))
         }
 
@@ -53,7 +51,6 @@ impl CmdUpload {
             cmd = cmd.arg(Arg::with_name("copy")
                 .long("copy")
                 .short("c")
-                .env("FFSEND_COPY")
                 .help("Copy the share link to your clipboard"));
         } 
         cmd