Giter Site home page Giter Site logo

Comments (3)

stappersg avatar stappersg commented on August 23, 2024

Upon seening

$ LANG=C sudo target/debug/erbium --help
[2021-01-02T21:31:06Z INFO  erbium] erbium 0.2.6 (e2d2af8)
[2021-01-02T21:31:06Z ERROR erbium] Error: Failed to load config from --help: No such file or directory (os error 2)

makes me think the original reported issue has been improved.

But an usage message isn't yet presented to user.

--- a/src/main.rs
+++ b/src/main.rs
@@ -63,6 +63,11 @@ async fn go() -> Result<(), Error> {
     } else {
         std::path::Path::new(&args[1])
     };
+    if config_file.starts_with("-") {
+        /* User is trying `-h`, `--help` or another option we don't support */
+        error!("Usage: {} <configfile>", args[0].to_string_lossy());
+        return Ok(());
+    }
     let conf = erbium::config::load_config_from_path(config_file)
         .await
         .map_err(|e| Error::ConfigError(config_file.to_path_buf(), e))?;

is something that compiles but never reaches true.

https://doc.rust-lang.org/std/path/struct.Path.html#method.starts_with says

Only considers whole path components to match.

And whole path starts with / ...

In other words: The reported issue got some attention, but still no information printed about flags.

from erbium.

isomer avatar isomer commented on August 23, 2024

I've not really come to a conclusion about how I want to handle command line arguments just yet, but you're right, this is a pretty nasty quality of life issue, so I've bodged in a solution similar to what you proposed.

I'm going to leave this issue open until I figure out how I want to handle parsing command line arguments properly. Do you think this is sufficient, or have I missed any other obvious cases?

from erbium.

stappersg avatar stappersg commented on August 23, 2024

Do you think this is sufficient

Yes.

And I suggest to close this issue.

from erbium.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.