summaryrefslogtreecommitdiff
path: root/snippets/ess-mode/command-args
diff options
context:
space:
mode:
Diffstat (limited to 'snippets/ess-mode/command-args')
-rw-r--r--snippets/ess-mode/command-args9
1 files changed, 9 insertions, 0 deletions
diff --git a/snippets/ess-mode/command-args b/snippets/ess-mode/command-args
new file mode 100644
index 0000000..87b6643
--- /dev/null
+++ b/snippets/ess-mode/command-args
@@ -0,0 +1,9 @@
+# -*- mode: snippet -*-
+# name: command args
+# key: cargs
+# --
+args <- commandArgs(trailingOnly = TRUE)
+if (length(args) != $1)
+ stop("Usage: `(file-name-nondirectory (buffer-file-name))` $2")
+
+$0 <- args[1]