# Struggling with trivial command line program

**URL:** <https://racket.discourse.group/t/struggling-with-trivial-command-line-program/2152>\
**Category:** Questions & Answers\
**Created:** [July 23, 2023, 10:39pm UTC](https://racket.discourse.group/t/struggling-with-trivial-command-line-program/2152 "2023-07-23T22:39:55Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![sorawee](https://avatars.discourse-cdn.com/v4/letter/s/ea5d25/32.png) [@sorawee](https://racket.discourse.group/u/sorawee)\
**Post date:** [July 23, 2023, 11:04pm UTC](https://racket.discourse.group/t/struggling-with-trivial-command-line-program/2152/2 "2023-07-23T23:04:15Z")

</div>

As I mentioned in [another post](https://racket.discourse.group/t/lang-cli-doesnt-work-or-no-longer-is-part-of-racket/2137/3), you do not need to use `cli`. Here’s the simplest variant:

```scheme
#lang racket/base

(displayln (expt (string->number (vector-ref (current-command-line-arguments) 0)) 2))

;; $ racket file.rkt 8
;; 64

```

If you want to handle command-line parsing in a more principled way, you can use `racket/cmdline`.

```scheme
#lang racket/base

(require racket/cmdline)

(define n
  (command-line
   #:args (number)
   (string->number number)))

(displayln (expt n 2))

;; $ racket file.rkt 8
;; 64
;; $ racket file.rkt
;; file.rkt: expects 1 <number> on the command line, given 0 arguments

```

---

_[View the full topic](https://racket.discourse.group/t/struggling-with-trivial-command-line-program/2152)._
