ratpoison-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[RP] argument parsing branch


From: Shawn Betts
Subject: [RP] argument parsing branch
Date: 21 Dec 2004 00:44:58 -0800
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3

Hi folks,

It's been a long time coming. I decided to take the icy plunge and add
proper argument handling to ratpoison.

I've made a branch, args, and committed the experimental code
there. To update to the branch, type:

cvs update -r args

to get back to the main branch

cvs update -A

I think it's fairly stable. It hasn't crashed on my for a while, and
it parsed my .ratpoisonrc.

The reason I haven't put it in the main branch is because the arg
parsing changed, slightly, how some commands work. I hope to fix them
so they behave the same as before. Also, not all commands have been
tested and their command definitions are probably wrong. I haven't had
a chance to go through them all yet. the 'set' command and its
associated functions still need to be fully converted.

Anyway, take a look if yer interested. I probably won't do any more
work on it until 2005 due to Christmas 'n' all. If you find crash
bugs, let me know.

Here's a rough description of how it works, to get you started:

each command now returns a cmdret* structure. It contains a string and
a boolean that decides whether its an error or normal output. commands
get an array of struct arg*. An arg is a union of different types. If
a command expects to get a number as the first argument, it would
access it like this:

args[0]->number

if it expects a frame:

args[0]->frame

args is NULL terminated.

a command should not use message for output. Instead it should return
a cmdret structure with the string it wishes to display. ratpoison
will then decide how the output is handled, depending on whether the
command was called interactively or not.

when ratpoison is asked to execute a command, it rips the command off
the beginning and sends the rest to parse_args (happens in action.c's
command). parse_args breaks the string up into a list of strings
(arguments). if its called interactively, fill_in_missing_args
converts the list of strings to a list of args and prompts the user to
fill in any missing args up to the user_command's required_args. If
its non-interactive, the string is converted to a list of args.

All argument verification is done before the command is called. If
there aren't enough args or the user typed a string when the command
required a number, errors are signalled (using cmdret) and the command
is never invoked.

If all that went okay, then the command is called. It should never
return NULL. if the command produces no output, it should return a
cmdret with output == NULL.

when a command is invoked non-interactively (ratpoison -c), errors are
printed to stderr, while normal output is sent to stdout. Errors are
no longer displayed in the bar. This should help scripts recover from
errors.

-Shawn




reply via email to

[Prev in Thread] Current Thread [Next in Thread]