Coder Social home page Coder Social logo

Comments (3)

Hyde46 avatar Hyde46 commented on May 23, 2024

Great idea, I like it a lot. This would make it much more user friendly to use!
Also, it means we can drop the command's options --name/--url and keep it to consuming one argument.

I have not yet worked with any uri parsing libraries in rust, but I assume it to be quite managable!
url seems to support what we are looking for. With the right checks we could distinguish between local files and remote ones.
Using this crate could allow more different kinds of remote sources for trove files, so the current code which fetches remote files might need to be looked at again. Currently, it's just expecting raw text which can be parsed as a trove.yml

Would you be interested in taking on the research for such a crate, and potentially implementation of the feature?

from hoard.

dfireBird avatar dfireBird commented on May 23, 2024

I was trying out the url crate (it's also in requwest::Url module) and I tried the sending the parse method three types of strings:

  1. http/https url
  2. Unix paths
  3. Windows paths

The parse method returns

  1. parsed Url object
  2. an Error with ErrorType variant RelativePathWithoutBase

For windows paths is where things get complicated. The windows paths gets parsed as a correct URL but with the drive letter being the scheme of URL and path being remaining path that didn't get parsed.
For example, the windows path C:\Programming\trove.yml gets parsed into a URL object with scheme as C and path as Programming\trove.yml.

So my proposal is to parse the string given by the user, if what they gave

  1. gets parsed into correct Url object (that is with http(s) as scheme) then use get request
  2. returns a RelativePathWithoutBase error and the OS is of type unix, then consider this as a path
  3. if parsed object is with a scheme of single letter (assuming most users don't have more than 26 drives) and the OS is Windows, then consider this also a path
  4. throw error, if anything other than that

from hoard.

Hyde46 avatar Hyde46 commented on May 23, 2024

Sounds great with that crate.

Regarding windows, I have not considered that OS generally for any of the functionality. I'm actually not sure if hoard even works in a windows terminal.

Agree with your proposal for the implementation. I'd say, go ahead!

from hoard.

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.