1.\" $Id: eif.1,v 1.10 2003/09/17 19:15:55 marcolz Exp $
2.Th EIF 1
3.Dd May 24, 2003
4.Dt EIF 1
5.Sh NAME
6.Nm eif
7.Nd Empire InterFace
8.Sh SYNOPSIS
9.Nm
10.Op Fl r
11.Op Fl D Ar varname value
12.Op Ar game
13.Sh DESCRIPTION
14.Ss What is eif?
15The
16.Nm
17program is an alternative to the empclient that comes with the Wolfpack
18Empire server.
19.Nm
20supports aliases with parameters, command history, substitution, etc.
21(Courtesy of GNU readline), variables, rudimentary conditionals and
22various forms of file redirection, piping and execution.
23.Ss What doesn't eif do?
24.Nm
25does not play your game for you. Use GEET or Xemp.
26.Nm
27knows next to nothing about the game of empire.
28.Nm
29does not use Xwindows, Sunview, etc. It is command line based.
30.Ss Autoconnection
31The variable "AUTOGAME" is set if there is a game name specified
32in the runtime options. I.E.,
33.Pp
34.Dl "eif mygame"
35.Pp
36would be equivalent to
37.Pp
38.Dl "setvar AUTOGAME mygame"
39.Pp
40from the
41.Nm
42command prompt.
43.Pp
44When the last line in the .eifrc file is:
45.Pp
46.Dl "connect ${AUTOGAME:?}"
47.Pp
48an autoconnect function is served.
49.Ss Runtime Options
50The following options are available:
51.Bl -tag -width indent
52.Fl D Ar varname value
53Equivalent to "setvar varname value" on the
54.Nm
55command prompt.
56.Fl r
57Disable reading of \fI$HOME/.eifrc\fR at startup.
58.El
59.Sh GENERAL SYNTAX
60There are 2 types of input. First, command level. This is the normal
61input. The second is "secondary" input, in which a command asks you a
62question. Such as doing a "map" command without specifying a range.
63.Ss Command Level
64Any line with a "#" as the first non\-space character is a comment line,
65and is ignored. Any line with a "&" as the first non\-space character is
66marked as only for secondary input, and is ignored. More on this later.
67.Pp
68"$var"s are replaced with the value of the variable "var". See below.
69.Pp
70Leading spaces on a command line are ignored, and not sent to empire.
71.Pp
72Multiple commands may be entered on the same line, with the commands
73seperated by a ";" character. IE, "nation ; power" will perform a
74nation, then a power command. ";"s inside of quoted strings (") are
75ignored for this.
76.Pp
77(NOTE that ";" will not seperate lines inside of telegrams and
78announcements. Otherwise you can't get ";" into them. Not sure if this
79is proper, but....)
80.Pp
81Output is redirected using ">".
82.Bl -tag -width "XXXXXXXX" -compact
83.It ">fname"
84direct this command's output into the file "fname". File must NOT exist.
85Command aborted if it does.
86.It ">>fname"
87this command's output is appended to the file "fname". The file may or may not
88exist.
89.It ">!fname"
90this command's output written to the file "fname". Any existing data in the
91file is wiped.
92.El
93Redirection supports ~/filename.
94.Pp
95Piping is supported, through the "|" type syntax.
96.Dl "list | more"
97will pipe the list command into more. Piping supports ~/filename.
98.Pp
99Aliases are supported. If the first non\-space string on a command
100line matches an alias, the string is replaced with the alias.
101NOTE that string in this context can have any characters but spaces,
102not withstanding any other special characters. (#,&,!!,^)
103.Pp
104Command history is supported.
105.Bl -tag -width "XXXXXXXX" -compact
106.It "^p"
107moves backwards in command history.
108.It "^n"
109moves forewards in command history.
110.It "!!"
111repeat last command.
112.It "!str"
113repeat last command which started with "str".
114.It "!?str?"
115repeat last command which contained "str".
116.It "!n"
117repeat the nth command, where n is a number.
118.It "!\-n"
119repeat the nth previous command, where n is a number.
120.It "^s1^s2"
121repeat the previous command, replacing string s1 with string s2.
122.El
123Other variants. Read the "history.texinfo" in the readline directory. And
124"readline.texinfo".
125Exec files are supported, along with exec's inside of execs.
126.Ss Secondary Input
127This is input that commands request. IE, asking questions that you didn't
128answer in the command line, or were unable to answer until the command was
129started.
130.Pp
131This creates problems for exec files, aliases, etc, since you are not always
132sure how many questions will be asked. Thus, you can mark secondary input
133lines with a leading "&". This prevents the secondary input lines as being
134attempted as commands.
135.Pp
136IE, "read >>read ; &y ; &n" will avoid that annoying problem of telegrams
137arriving while reading.
138.Pp
139And, "build plane 16,2 ; &fighter 2 ; & " fixed the problem of
140not being able to specify multiword entries in a single line.
141(Typing "build plane 16,2 fighter 2 100" would try to build
142you a 'fighter 1' at tech 2.) This example is outdated now.
143.Pp
144Preconditioning:
145.Bl -tag -width XX
146.It leading spaces are removed.
147Spaces after the "&", as well as the "&", are removed.
148.It trailing spaces are removed.
149("ssm 2 " is not == "ssm 2".)
150.El
151.Pp
152This preconditioning is not done for telegrams and announcements,
153through a special case which examines the prompt string.
154.Pp
155.Ss Escaping
156If one the characters '$' ';' '"' '\\'
157is not to be parsed by eif, it can be escaped with a \\. Note that a '$'
158can also be escaped as "${}".
159.Pp
160.Ss Aliases
161.Bl -tag -width "XXXXXXXXXXXXXXXXXXXXXX" -compact
162.It 'alias'
163list all the aliases
164.It 'alias word'
165show what alias 'word' is.
166.It 'alias word command'
167create/change alias 'word' to command.
168.It "'alias word ""command""'"
169ditto, but the "s are removed. Allows embedding of several commands inside
170one alias. ie, 'alias dd "dump #0 >!dmp; map #0 >!map"'
171.Pp
172.It 'unalias word'
173delete the alias for 'word', if it exists.
174.El
175.Pp
176The variables $0, $1, $2, ... are supported for aliases.
177They are the "words" in the command that the alias is working on.
178.Pp
179Also, these variables can be conditional.
180.Bl -tag -width "XXXXXXXXXXX" -compact
181.It ${N:\-word}
182uses "word" if argument N does not exist.
183.It ${N:?word}
184prints out "word" and aborts command if N does not exist.
185.It ${N:+word}
186uses nothing if argument N does not exist.
187.El
188.Pp
189"words" are space delimited, or surrounded by "s.
190.Pp
191Example:
192.Dl "local% alias tt ""echo 0\-$0  1\-$1  2\-$2"""
193.Dl "local% tt a b c d e f"
194.Dl "0\-tt 1\-a 2\-b c d e f"
195.Dl "local% tt ""a b"" c d e f"
196.Dl "0\-tt 1\-a b 2\-c d e f"
197.Ss Exec
198.Bl -tag -width "XXXXXXXXXXXXXX" -compact
199.It exec filename
200execute the commands in "filename".
201.El
202.Pp
203exec's are allowed to be recursive, but at this time there is a
204minor bug when the exec file ends on secondary input. Input is
205redirected to stdin, and not the calling exec file.
206Fixed some day.
207.Pp
208Output redirection handles recursive execs.
209.Ss Variables
210.Bl -tag -width "XXXXXXXXXXXXXXXXXX" -compact
211.It $$
212process id.
213.It $<
214read from stdinput.
215.It ${}
216a literal $.
217.It ${<:%word}
218read from stdinput, using "word" as a prompt.
219.It $%name
220retrieve "name" from the runtime environment, using getenv().
221.It $name
222replace with value of "name".
223.Pp
224.It ${name}
225replace with value of name.
226.It ${name:\-word}
227if name is not set, or null, use "word" instead.
228.It ${name:=word}
229if name is not set, or null, use "word", and set variable to "word".
230.It ${name:?word}
231if name not set, or null, print "word" and abort command.
232.It ${name:+word}
233if name not set, or null, substitute nothing.
234.It ${name:%word}
235use "word" as prompt if "name" == "<". ":%word" ignored elsewhere.
236.Pp
237.It setvar name string
238.It "setvar name ""string"""
239.It setvar name
240.It unsetvar name
241.El
242.Pp
243If %name is used instead of name as first argument to either setvar or
244unsetvar, the environment is used instead of eif's local variable scope.
245.Ss Commands
246The current list of commands are:
247.Bl -tag -width "XXXXXXXXXX" -compact
248.It alias
249setting aliases.
250.It unalias
251remove an alias.
252.It echo
253print out the rest of the line.
254.It beep
255make a beep.
256.It games
257show the games that are configure in.
258.It addgame
259add a game.
260.It connect
261connect to a game.
262.It kill
263kill a hung game process. (Only works if server supports it.)
264.It try
265try a country/rep at a given game.
266.It trykill
267kill a hung game process for a country/rep at a given game.
268.It exit
269quit the program
270.It cmdlist
271list these commands
272.It exec
273execute a file. Supports ~/filename.
274.It runfeed
275execute a program, and use its output as
276.Nm
277commands.
278.It history
279display a listing of the command history.
280.It setvar
281set a variable.
282.It unsetvar
283delete a variable.
284.It @
285pass the rest of the command off to the system to execute.
286.It if
287Uses /bin/test, and stops at endif. Disables command if test returns
288false. Can be nested. Cannot span exec files.
289.It elseif
290Next case in an if sequence, same testing as 'if'.
291.It else
292Last case in an if sequence.
293.It endif
294Ends an 'if' sequence.
295.El
296.Pp
297The file "$HOME/.eifrc" is read in and executed as an exec file.
298.Ss Other Things
299When "connecting" to a game, the program does a chdir to the
300directory specified in the "addgame" command. Thus, you
301can have multiple games, in multiple directories, so that
302your data files for things like "ve" don't get messed up.
303NOTE that the directory name in "addgame" is relative to
304your home directory.
305.Sh EXAMPLES
306.Ss Example .eifrc
307.nf
308# Games
309addgame cvis blitz.wolfpackempire.com 6789 visitor visitor .empire.chg
310addgame zvis blitz.wolfpackempire.com 5678 visitor visitor .empire.zeb
311
312# Read system eifrc
313exec /usr/local/lib/eif/eifrc.include
314
315# Prevent name clashes by defining abbreviations ourselves
316alias	ex	"expl c ${1} 1"
317alias	pl	plane
318alias	sh	ship
319alias	m	map
320alias	b	bmap
321alias	sh	ship
322alias	x	exit
323alias	c	connect
324
325# Run the sat command on all planes in wing S (see eifrc.include)
326alias	sats	"pwith S do sat \\[\\]"
327
328# If a game was passed as argument, connect to it.
329conn ${AUTOGAME:?}
330.fi
331.Sh SEE ALSO
332.Xr readline 3
333.nf
334http://www.stack.nl/~marcolz/empire/
335http://www.wolfpackempire.com/
336.fi
337.Sh COPYRIGHT
338By far most of the code is from the original author: Doug Hay. Very
339little has been modified, but most of that is done by Marc Olzheim
340(marcolz@stack.nl)
341