Coder Social home page Coder Social logo

Parsing key-value pairs about commandline HOT 7 OPEN

ericnewton76 avatar ericnewton76 commented on June 29, 2024 11
Parsing key-value pairs

from commandline.

Comments (7)

ericnewton76 avatar ericnewton76 commented on June 29, 2024

Comment by alastairtree
Sunday May 31, 2015 at 12:43 GMT


I have too been looking for this feature. Anyone find/build anything?

from commandline.

ericnewton76 avatar ericnewton76 commented on June 29, 2024

Comment by gsscoder
Saturday Jun 06, 2015 at 17:15 GMT


Happy you like it... I'm recently back to work on the project.

When 2.0 swirch to beta, a lot is planned. I was thinking to something
similar too...

Maybe adding a form of post-value processing.

Regards.

Il domenica 31 maggio 2015, alastairtree [email protected] ha
scritto:

I have too been looking for this feature. Anyone find/build anything?


Reply to this email directly or view it on GitHub
gsscoder/commandline#122 (comment)
.

Giacomo Stelluti Scala
_Information Technology _Consultant

from commandline.

ericnewton76 avatar ericnewton76 commented on June 29, 2024

Comment by TheFanatr
Saturday Oct 21, 2017 at 01:42 GMT


Any update on this?

from commandline.

DominikWiesend avatar DominikWiesend commented on June 29, 2024

I'm really waiting for this.

from commandline.

sybaris avatar sybaris commented on June 29, 2024

Hello

Waiting this feature, I think I will use something like the following code.

It's ok for
key1=value1
key2="value2"
but not for
key3="foo""bar"

Do you have something better to propose ?

Thanks for advance.
Sybaris

  ```

[Option("Dico", HelpText = "Test")]
public IEnumerable Dico { get; set; }

    public Dictionary<string, string> GetDico()
    {
        const string KEY_VALUE1 = @"(\w+)\=(\w+)";
        const string KEY_VALUE2 = @"(\w+)\=\""([.|\""]+)\""";

        Dictionary<string, string> result = new Dictionary<string, string>();
        foreach (var item in Dico)
        {
            bool matchKeyValue1 = Regex.IsMatch(item,KEY_VALUE1);
            bool matchKeyValue2 = Regex.IsMatch(item, KEY_VALUE2);
            if (!(matchKeyValue1 || matchKeyValue1))
                throw new Exception($"Parameter {item} does not match the requirements.");
            string regexElected = matchKeyValue2 ? KEY_VALUE2 : matchKeyValue1 ? KEY_VALUE1 : "";
            Debug.Assert(!string.IsNullOrEmpty(regexElected));
            string key = Regex.Match(item, regexElected).Groups[1].Value;
            string value = Regex.Match(item, regexElected).Groups[2].Value;
            result.Add(key, value);
        }
        return result;
    }

from commandline.

AceCoderLaura avatar AceCoderLaura commented on June 29, 2024

Definitely a feature worth having. I'm currently using environment variables for key-value pairs. It's a bit yuck but it works for my scenario. Would be good to do it properly with this library at some stage.

from commandline.

carlo-setldpay avatar carlo-setldpay commented on June 29, 2024

Is there any update on this?

from commandline.

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.