Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8427765
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:52:06+00:00 2026-06-10T04:52:06+00:00

Using tools.cli, how can I can I create a non-optional argument with optional ones?

  • 0

Using tools.cli, how can I can I create a non-optional argument with optional ones?

I have a function

(defn parse-opts
  [args]
  (cli args
  ["-f" "--ifn" "input file"]
 (optional ["-o" "--outp" ".csv pipe delimited output file" 
      :default "assess_pro_out.csv"] identity)
 (optional ["-d" "--debug" "Debug flag for logging." :default 0 
      :parse-fn #(Integer. %)])))

that compiles but produces

Exception in thread "main" clojure.lang.ArityException: 
Wrong number of args (2) passed to: PersistentVector

when I run my main program without arguments.

If this option is made like the rest

(optional ["-f" "--ifn" "input file"] identity)

everything works fine.

I just want one parameter to be non-optional. What am I doing wrong?

I do have a workaround for this, but I’d still like to know if it is okay to mix optional and non-optional arguments to cli.

(defn -main 
[& args]
(let [opts (parse-opts args)
      start-time (str (Date.))
      parsed-csv-data (if-not (:ifn opts)
                       (do
                       (println "Usage: assess-chk [-f -ifn] input-file-name")
                       (System/exit -2))
                       (utl/fetch-csv-data (:ifn opts)))

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T04:52:08+00:00Added an answer on June 10, 2026 at 4:52 am

    You’re using an old version of tools.cli (probably v0.1.0). For that version it appears that you should use (required ...) for required options. See the docs at https://github.com/clojure/tools.cli/tree/a741b23f230123179fc518af772f1c057058f7d2

    In the current version of tools.cli, options are always optional and the optional and required functions are removed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any tools using which I can use to create Windows forms from
I am using jQuery Tools v1.2.7 and jQuery v1.7.2. I have the following code:
I am using the jQuery Tools Scrollable plugin - http://flowplayer.org/tools/scrollable.html#navigator I have created a
I am implementing a CLI tool using Perl. What are the best-practices we can
OS: WinXP Server: Xampp (Apache) After using the zend cli tool to create an
HI, I have been assigned a task of exploring unit testing using tools available
How can you properly read RRD files using Java? We are using tools like
i'm trying to learn how i can develop on xcode 4 using tools to
Background I've been timing some HTTP requests via the CLI using time and tools
I'm using Visual Studio 2005 and I have a C++/CLI project I'm using as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.