Skip to Main Content
Python Command Line Tools
book

Python Command Line Tools

by Alfredo Deza, Noah Gift
May 2020
Intermediate to advanced content levelIntermediate to advanced
117 pages
1h 57m
English
Pragmatic AI Labs
Content preview from Python Command Line Tools

Chapter 10: Command-line Rosetta Stone

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.

R Hello World

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python CI/CD for the Command-Line

Python CI/CD for the Command-Line

Alfredo Deza, Noah Gift
Intuitive Python

Intuitive Python

David Muller
Learning Python Networking - Second Edition

Learning Python Networking - Second Edition

José Manuel Ortega, Dr. M. O. Faruque Sarker, Sam Washington

Publisher Resources

ISBN: 61619PAIMLPurchase LinkOtherOtherOther