Questions tagged [getopt-long]

Getopt::Long is a command line switch parsing library for Perl. For C-programming: The getopt and getopt_long functions automate some of the chores involved in parsing typical unix command line options.

The Getopt::Long Perl module is a parser for the POSIX command line switch syntax with GNU extensions. Both the traditional -s single character switches and the longer --longer switches are supported.

For C-programming: The getopt and getopt_long functions automate some of the chores involved in parsing typical unix command line options. For details, please see here.

190 questions
0
votes
1 answer

Can ruby's GetOptLong process spaces in option arguments?

What I'm trying to do is pass an argument for an option in a ruby script that will be a unix command. The command may (probably will) involve greps, pipes and possible lots of other stuff. Essentially, what I'm wondering is, can a GetOptLong option…
RTF
  • 6,214
  • 12
  • 64
  • 132
0
votes
0 answers

forcing getopt_long() to match complete argument

I'm using dashes to handle large option names, such as: --load-ptest --load-program Both of these options take no arguments for simplicity. Here's the code snippet I'm using as an example: enum FLAGS{ LOAD_PTEST_FLAG, …
Franks
  • 50
  • 8
0
votes
2 answers

Cpp: How can I get the long-name of an option using getopt.h

Hey I have a function to check the given arguments for my program. I want to get the long-name of the given users argument. Problem is currently he gives me weird high numbers example 32758 while my struct has only 9 elements... I have to use it for…
Muddyblack k
  • 314
  • 3
  • 16
0
votes
2 answers

Why I cant catch bad option when give unknown option to getopt_long?

So, I have next code: #include #include #include #include #include #include #include // #include"main.hpp" // #include"functions.cpp" int main(int argc, char** argv) { …
0
votes
1 answer

getopt_long `--' options does not work for switch statement

I have this c program which use getopt_long to parse - and -- options, but when i parse -- options the optarg does not work for the program. how can i assing the optarg value for the varibale if -- is parsed for the program. #include…
devMe
  • 126
  • 10
0
votes
1 answer

getopt_long problem

i have a problem with parsing arguments from a program that i'm writing, the code is below: void parse_args(int argc, char** argv) { char ch; int index = 0; struct option options[] = { { "help", no_argument, NULL, 'h' …
funnyCoder
  • 787
  • 2
  • 10
  • 30
0
votes
1 answer

Multiple definition of short_options and long_options with getopt

I am writing my own implementation of cat and using getopt_long to parse command line arguments. I have three files: one with function headers, one with function definitions, and one with main. Here is the header file: #ifndef…
e7min
  • 41
  • 2
  • 9
0
votes
1 answer

Perl display selected data with a specific argument with Getopt::Long

I have a file with input this Store::ID_AZD|AZD|Category::1314559|Séries Store::ID_AZD|AZD|Category::1314557|Emissions Store::ID_AZD|AZD|Category::1314560|Jeunesse Store::ID_AZD|AZD|Category::1314558|Information Store::ID_FRA|CHANNEL…
Seth
  • 364
  • 1
  • 16
0
votes
1 answer

Right way running Getopt::Long::GetOptions in a subroutine

Hi I'm using Debian Linux and Perl 5.28 and try to run in a subroutine (method of a class). The calling part is produced by a toolkit object $TK: # Usage sugar: help, man and version for the CLI my $IS_MAN; # Flag show man page my $IS_HELP; # Flag…
huckfinn
  • 644
  • 6
  • 23
0
votes
0 answers

getopt_long confusion, flag setting with single-char switches

I'm parsing command line options using getopt_long based on the example from the man page. That example does something a bit sneaky, it includes two flag-setting options in long_options but does not list those in the short form parameter string in…
Maury Markowitz
  • 9,082
  • 11
  • 46
  • 98
0
votes
1 answer

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 add a new element to long_options vector concerning…
0
votes
1 answer

Exit from the script if required arguments not found in Perl

I have script which should take two arguments from command line. To achieve that, I am using Getopt::Long Perl module. Here is the script: #!/usr/bin/perl use strict; use warnings; use Getopt::Long 'HelpMessage'; GetOptions( 'node|n=s' => \my…
vkk05
  • 3,137
  • 11
  • 25
0
votes
1 answer

How to make getopt skip the program name and the script name before processing arguments?

I think I'm trying to figure out to arrange things so that getopt_long skips an argument. I wrote a shared library / dll and I use it from C or from a lua script. The bit of code that parses the CLI is in the shared library / dll, which is in C…
101010
  • 14,866
  • 30
  • 95
  • 172
0
votes
1 answer

getopt order of argv when passing multiple arguments to one option

I'm trying to pass multiple arguments to one option. For example, (1) ./someProgram -f opt1 opt2 opt3 -j opt -d. (2) ./someProgram -f /dir/dir/* -j opt -d. My settings for getopt_long looks like this. const char *short_opt = "hp:j:o:f:"; struct…
user8777898
0
votes
0 answers

Passing long and short CLI options with & without space

I wish to pass long and short CLI options. I have tried below for short options: #!/bin/bash while getopts d:t:r: option do case "${option}" in d) c_date=${OPTARG};; t) c_type=${OPTARG};; r) c_date_range=${OPTARG};; esac done shift $((OPTIND…
S R
  • 657
  • 3
  • 10
  • 21