Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: Kenneth Adam Miller <kennethadammiller@gmail.com>
To: caml users <caml-list@inria.fr>
Subject: [Caml-list] complications with Arg.parse_argv
Date: Mon, 24 Nov 2014 12:42:30 -0500	[thread overview]
Message-ID: <CAK7rcp9Qn8_PDGiHhC+nVGN7q7R5Ww+w3DLpCMjWH6VkaD+PJg@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

So, I'm using a library that calls Arg.parse to build up it's inputs in
another data structure. I don't want to rewrite any code, and I'm consuming
the library in a different way than how the binary consumes it, which is
just to feed it input from the command line.

Not wanting to replicate code in two locations, I chose to use
Arg.parse_argv, and supplied it with an array that would normally be on the
command line. For some reason, supplying the exact same speclist as what
was used in the original statement that works as a command line tool
doesn't result in the parameters being parsed.

command line tool:
Arg.parse speclist anon usage;
get_program () (* consumes the mutable list that speclist modified *)

(* speclist modifies a mutable list used to hold arguments *)

my code that consumes speclist as a library:

Arg.parse_argv custom_arguments speclist anon usage
get_program () (* exact same function as above, exact same variables to
Arg.parse* *)

For some reason, Arg.parse_argv seems to complete, but when get_program
proceeds, it sees the mutable argument list as being empty. Why?

[-- Attachment #2: Type: text/html, Size: 1324 bytes --]

             reply	other threads:[~2014-11-24 17:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-24 17:42 Kenneth Adam Miller [this message]
2014-11-24 18:16 ` Gabriel Scherer
2014-11-24 18:22   ` Kenneth Adam Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7rcp9Qn8_PDGiHhC+nVGN7q7R5Ww+w3DLpCMjWH6VkaD+PJg@mail.gmail.com \
    --to=kennethadammiller@gmail.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox