Coder Social home page Coder Social logo

Allow escaping strings about kotlin-argparser HOT 6 CLOSED

Cydhra avatar Cydhra commented on May 24, 2024
Allow escaping strings

from kotlin-argparser.

Comments (6)

Ceiridge avatar Ceiridge commented on May 24, 2024

xaxa more work

from kotlin-argparser.

xenomachina avatar xenomachina commented on May 24, 2024

All of these, except the support for newlines or unicode escaping, should already be handled by your shell. Have you encountered a situation where this is not the case?

from kotlin-argparser.

Cydhra avatar Cydhra commented on May 24, 2024

Yes. All cases, where the argument parser is not used for arguments from a shell, but another input source

from kotlin-argparser.

Cydhra avatar Cydhra commented on May 24, 2024

I did an error in my thought process. The problem is that parsing a command line is a common task, if it is not done by a shell, but the lib does not offer a solution. So basically, everyone who handles a command line would have to parse it theirself before invoking ArgParser with the argument array.
It would be nice to have a secondary constructor of ArgParser that would also parse a complete command line with respect to quotation and escaping.

from kotlin-argparser.

xenomachina avatar xenomachina commented on May 24, 2024

Kotlin-argparser, like most (possibly all) other command line argument parsers expects a list/array of command line arguments. This is the way the Kotlin (and Java, and even C) passes unparsed command line arguments to your application.

It sounds like what you need is something that takes a single-string command-line and turns it into a segmented argument array. I'm not convinced this falls within the scope of Kotlin-argparser. This sort of initial parsing is not trivial, and would probably be better handled by a separate library.

I know in Python there's the shlex module. I don't know of an equivalent for Java or Kotlin. This Stack Overflow question has a few answers, but none seem really "complete".

Out of curiosity, where are you getting these command line strings?

from kotlin-argparser.

Cydhra avatar Cydhra commented on May 24, 2024

Well, I kind of expected it would be declared out of scope :D
I am working on a game-mod and among other things added a terminal-like interface to interact with different elements for debugging and configuring purpose. The terminal obviously does not invoke a shell to parse its input.

from kotlin-argparser.

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.