1
# general-commands.rb: various global scope commands
2
# copyright (c) 2009 by Vincent Fourmond
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details (in the COPYING file).
14
require 'ctioga2/utils'
15
require 'ctioga2/commands/general-types'
16
require 'ctioga2/commands/parsers/file'
20
Version::register_svn_info('$Revision: 155 $', '$Date: 2010-06-21 21:41:32 +0200 (Mon, 21 Jun 2010) $')
24
# General scope commands.
26
CmdGroup.new('general', "General commands",
27
"General scope commands", 1000)
30
CommandLineHelpOptions = {
31
'pager' => CmdArg.new('boolean')
34
# Display help on the command-line
35
CommandLineHelpCommand =
36
Cmd.new("command-line-help", 'h',
37
"--help", [ ], CommandLineHelpOptions) do |plotmaker, options|
38
plotmaker.interpreter.doc.display_command_line_help(options)
42
CommandLineHelpCommand.describe("Prints help on command-line options and exits",
44
Prints helps about short and long options available when run from the
48
# Prints the version of ctioga2 used
49
PrintVersion = Cmd.new("version", '-V', "--version", []) do |plotmaker|
50
puts "This is ctioga2 version #{CTioga2::Version::version}"
53
PrintVersion.describe("Prints the version",
54
"Prints the version of ctioga in use",
59
Cmd.new("include", '-f', "--file",
60
[ CmdArg.new('file'), ]) do |plotmaker, file|
61
plotmaker.interpreter.run_command_file(file)
64
RunCommandFile.describe("Runs given command file", <<EOH, GeneralGroup)
65
Reads the file and runs commands found in them, using the ctioga language.
66
> ctioga2 -f my_file.ct2
69
# Evaluate a series of commands.
70
EvalCommand = Cmd.new("eval", '-e', "--eval",
71
[ CmdArg.new('commands'), ]) do |plotmaker, string|
72
plotmaker.interpreter.run_commands(string)
75
EvalCommand.describe("Runs the given commands", <<EOH, GeneralGroup)
76
Runs the given strings as commands, as if given from a command file.
81
Cmd.new("verbose", '-v', "--verbose", [ ]) do |plotmaker|
82
CTioga2::Log::set_level(Logger::INFO)
85
VerboseLogging.describe("Makes ctioga2 more verbose", <<EOH, GeneralGroup)
86
With this on, ctioga2 outputs quite a fair amount of informative messages.
89
# Write debugging information.
91
# \todo this should be the place where a lot of customization of
92
# the debug output could go - including channels or things like
93
# that. To be seen later on...
95
Cmd.new("debug", nil, "--debug", [ ]) do |plotmaker|
96
CTioga2::Log::set_level(Logger::DEBUG)
99
DebugLogging.describe("Makes ctioga2 write out debugging information",
101
With this on, ctioga2 writes a whole lot of debugging information. You
102
probably will not need that unless you intend to file a bug report or
103
to tackle a problem yourself.
108
Cmd.new("echo", nil, "--echo", [ ]) do |plotmaker|
109
STDERR.puts "Command-line used: "
110
STDERR.puts plotmaker.quoted_command_line
113
EchoCmd.describe("Prints command-line used to standard error",
115
Writes the whole command-line used to standard error, quoted in such a
116
way that it should be usable directly for copy/paste.