Skip to content

Proposal to add quoted parameters for command line arguments #46

@pawelkax

Description

@pawelkax

Hi,
Could we have opportunity in configshell-fb to pass quoted strings as arguments?
It would be nice to have it. In our software we use whitespace separated arguments
and we also create similar program to targetcli based on configshell. We would like to have compatibility in our code.
Passing such string should work: sample_arg="test test1"

The proposed code would look like this (it is taken from Datera/configshell#2):

diff --git a/configshell/shell.py b/configshell/shell.py
index bb4dd32..f4caa94 100644
--- a/configshell/shell.py
+++ b/configshell/shell.py
@@ -19,7 +19,8 @@ import os
 import six
 import sys
 from pyparsing import (alphanums, Empty, Group, OneOrMore, Optional,
-                       ParseResults, Regex, Suppress, Word)
+                       ParseResults, Regex, Suppress, Word,
+                       QuotedString, Or)

 from . import console
 from . import log
@@ -119,7 +120,8 @@ class ConfigShell(object):
         # Grammar of the command line
         command = locatedExpr(Word(alphanums + '_'))('command')
         var = Word(alphanums + ';,=_\+/.<>()~@:-%[]')
-        value = var
+        qvar = QuotedString('"', unquoteResults=True)
+        value = Or([qvar, var])
         keyword = Word(alphanums + '_\-')
         kparam = locatedExpr(keyword + Suppress('=') + Optional(value, default=''))('kparams*')
         pparam = locatedExpr(var)('pparams*')

Thanks,
Pawel

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions