93 questions
-1
votes
2
answers
71
views
When passing a filename as an argument to Ruby script, why does OptionParser read the contents of the file instead of the name?
I am writing a script to interact with a GitHub environment. For certain use cases, I need to limit my script's scope to a list of users, which I store in a newline-delimited file. I want to pass the ...
1
vote
0
answers
23
views
Why is the input string read by OptParser?
I am currently creating a launcher (launcher.py) in Python 2.7 which can be used from GUI and terminal input. The launcher combines already eisting Software, that has its own GUI and its own terminal ...
0
votes
1
answer
67
views
Perform checks that include multiple options
I have
type Month = Int
parseMonths :: OP.Parser (Month, Month)
parseMonths =
liftA2 (,)
(OP.option
(OP.eitherReader $
parseNumber "month" (\n -> 1&...
1
vote
1
answer
1k
views
C: getopt_long() always returns invalid option
I'm trying to add a new option to an already working C program using getopt_long. The option I want to add is -S but every time I try to run the code I get:
./HidCom: invalid option --'S'
I simply ...
0
votes
1
answer
61
views
I have three flags in OptionParser but it only gives access to two of them
I am building a CLI gem with Ruby and I'm using OptionParser to add flags with arguments. Whenever one flag is called with an argument a function get's called.
I have three flags. My problem is, when ...
0
votes
1
answer
98
views
python3.7 optionparser input option with asterisk(*) becomes a file in the folder
Env:
python3.7
OptionParser with a option [ add_option('-t', '--target', action='append', dest='targets') ]
OS: CentOS7.6
Problem:
So I am using this option to input a list of targets, and ...
1
vote
1
answer
366
views
Is there any way to take inputs for a option created using parser.add_option, and not take any input for the same option?
Now when I type " python openweather.py --api=key --city=London --temp=fahrenheit " in command prompt, I get the desired output of temperature in fahrenheit or even if celcius is entered (" --temp=...
1
vote
1
answer
209
views
Is it possible to send an 'OptionParser' object as input arguement to run main of imported python module?
There are two python scripts, 'script1.py' and 'script2.py'.
'script1.py' uses OptionParser to parse command line arguments.
The contents of 'script1.py' look something like this
from optparse ...
7
votes
2
answers
4k
views
Ruby OptionParser Short Code for Boolean Option?
I am using Ruby's OptionParser (require 'optparse') processing a "verbose" option that can be either true or false. It is in the code like this:
parser.on('-v', '--[no-]verbose', 'Verbose mode') do ...
1
vote
1
answer
345
views
Crystal lang takes option parameters from OptionParser when it shouldn't
I started paying around with Crystal lang, I want to use OptionParser to show a help text, however -h will be interpred by Crystal instead of OptionParser
I am using the example from https://crystal-...
0
votes
2
answers
618
views
How to execute python class modules along with pytest and option parser?
main
|--> src
|--> custom_calculation.py
|--> test_custom_calculation.py
custom_calculation.py
def calc_total(a,b):
return a+b
def calc_multiply(a,b):
return a*b
...
3
votes
2
answers
2k
views
Ruby OptionParser not parsing -- commands properly
Here is a stripped down version of OptionParser
OptionParser.new do |opts|
opts.on('-f', '--format FORMAT', 'output format (text, html, yml, json, xml)') do |format|
options['format'...
1
vote
1
answer
678
views
Option Parser does not match argument
I have a simple python (v2.7) script (test.py)
#!/usr/bin/python
import sys
from optparse import OptionParser
def main():
parser = OptionParser()
parser.add_option("--files", dest="files",
...
2
votes
2
answers
845
views
unittest for command line arguments
How do I unit test my script for incorrect command line arguments?
For example,
my_script.py -t
should give an error since -t flag is not present, as shown in the code below:
parser = ...
1
vote
0
answers
35
views
OptionParser, requiring subparameters
I'm trying to figure out how to define subparameters for one of my parameters. This is what I have that is NOT working:
require 'optparse'
options = {}
OptionParser.new do |parser|
parser.on("-r",...