File: sum2.R

package info (click to toggle)
r-cran-argparser 0.7.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 252 kB
  • sloc: sh: 13; makefile: 2
file content (19 lines) | stat: -rwxr-xr-x 545 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/Rscript

library(argparser, quietly=TRUE)
    
# Create a parser
p <- arg_parser("Calculate the sum of two numbers")

# Add command line arguments
# Note: The values for the numbers argument have to provided as a comma
#       separated string, since we are specifying a position argument here.
p <- add_argument(p, "numbers", help="comma separated list of two numbers to add",
	nargs=2, type="numeric")

# Parse the command line arguments
argv <- parse_args(p)

# Do work based on the passed arguments
cat( sum(argv$numbers), "\n")