May 2020
Intermediate to advanced
117 pages
1h 57m
English
This chapter serves as a guidebook for users coming from another language. The source code can be found here. The same style, hello world command-line tool is written in many languages.
This step is an example of a hello world command-line tool in R. The source code is here.
#!/usr/bin/env Rscript
#Hello World R command-line tool
#
suppressPackageStartupMessages(library("optparse"))
parser <- OptionParser()
parser <- add_option(parser, c("-c", "--count"), type = "integer",
help = "Number of times to print phrase",
metavar = "number")
parser <- add_option(parser, c("-p", "--phrase"),
help = "Phrase to print")
args <- parse_args(parser)
# Function to Generate Phrases
phrasegen <- function ...