Code Monkey home page Code Monkey logo

Comments (6)

tversteeg avatar tversteeg commented on July 23, 2024 1

I think a has_required_flag member makes a lot of sense for this situation. Sounds look a good clean solution!

from emplace.

jayvdb avatar jayvdb commented on July 23, 2024 1

It might make more sense to have a hook which is given the entire command line and is able to reject it - then the hook would be usable for other special cases where a declarative approach is a lot of effort

from emplace.

tversteeg avatar tversteeg commented on July 23, 2024

Hi @jayvdb, unfortunately I'm not maintaining this application anymore, so I won't pick up this issue. Any PR's are greatly appreciated though!

from emplace.

jayvdb avatar jayvdb commented on July 23, 2024

I am happy to build the fix for this.

I've had a poke around, and notice the problem of local project package installs is unique to npm. All others are either global/system or per-user installs. Also none of the open issues are proposing another package manager which would have the same problem.

A quick fix is to change npm to be similar to rustup which has a sub_commands of "component add".

i.e. sub_commands for npm could be install -g and install --global. However that would not catch npm install foo -g / npm install foo --global.

To properly solve his without regressions, IMO the package managers need a member has_required_flag or similar, which for npm would return -g and --global. This feels a bit like overkill because there is no other package manager which currently needs this. Maybe I have missed a better alternative.

from emplace.

jayvdb avatar jayvdb commented on July 23, 2024

Digging a little deeper, I wonder if it would be OK to add a CaptureFlag::Invalidating("--path") to cargo.rs to replace has_invalidating_flag, and CaptureFlag::Required(["-g", "--global"]) to npm.rs which would tell catch that the line should be ignored unless it was found.

Invalidating is easy as it presence in the command args could be handled in handle_capture_flags, which could return a bool to tell capture to ignore the line. Multiple Invalidating would be OR'd.

Required is slightly more involved, as capture would need to see if Required is present in the package managers capture_flags() return value before processing the command args, and verified that it was seen. Required would take a vec of equivalent flags that are OR'd (e.g. "-g" or "--global" are required), and multiple Required would be AND'd.

This approach would mean that flag processing is still declarative, but doesn't involve creating new members like has_required_flag that are unnecessary for most package managers.

from emplace.

tversteeg avatar tversteeg commented on July 23, 2024

This sounds like a good solution! I think this would make the implementation a lot cleaner.

from emplace.

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.