From: adrian15 <adrian15@raulete.net>
To: grub-devel@gnu.org
Subject: grub2 common argument parser
Date: Sat, 09 Jun 2007 09:34:41 +0200 [thread overview]
Message-ID: <466A5811.6060303@raulete.net> (raw)
I have an idea that I am not able to implement in bash because I have
no time. It consists about an xml file that has all the arguments of a
command and how they should be (a file, a device, an string), if an
argument is compulsory or not, if two arguments are incompatible.
This xml file can be read by a GUI program that can present you a GUI
to any of your console programs. Like if it was an interactive 'man'.
Each option has its explanation and you can fill the empty boxes.
And the next step is that the man files instead of being man files
would be these xml files.
Well one thing more or less equivalent that could be done in grub2 is a
"grub2 common argument parser".
I think it can be done because most of the argument types are the same
ones: FILE, ENVVAR, MODULE, TERM, EXPRESSION, DEVICENME, PATTERN.
Why we should let every command parse its own arguments when we could
have a common argument parser.
The idea is the following one:
When you define a command argument by the means of options...
static const struct grub_arg_option options[] =
{
{"file", 'f', 0, "search devices by a file (default)", 0, 0},
{"label", 'l', 0, "search devices by a filesystem label", 0, 0},
{"set", 's', GRUB_ARG_OPTION_OPTIONAL, "set a variable to the first
device found", "VAR", ARG_TYPE_STRING},
{0, 0, 0, 0, 0, 0}
};
Hey... there's something about it on the search.c code but it is not
complete. It seems that the 3rd filed is what I need and maybe the last one.
Hey it seems that this is already in the TODO list.
(normal/arg.c)
case ARG_TYPE_DEVICE:
case ARG_TYPE_DIR:
case ARG_TYPE_FILE:
case ARG_TYPE_PATHNAME:
/* XXX: Not implemented. */
That's a good and bad piece of news. That means that I will have to
reimplement the test -e command in a future in order to take advantage
of this implementation.
The ARG_TYPE_FILE check is only trying to open it with grub_file_open ()
or maybe the grub_file_stat ... hummm... someone on the mailing list
adviced me to use this second one but I do not find it.
It seems for me that the filesystem modules or drivers do only have
these commands:
.name = "ext2",
.dir = grub_ext2_dir,
.open = grub_ext2_open,
.read = grub_ext2_read,
.close = grub_ext2_close,
.label = grub_ext2_label,
.next = 0
A question for marco_g
==========================
This .next is for file iteration inside a folder, maybe?
And another question for everybody... do we need to implement a
grub_file_stat function or not?
adrian15
reply other threads:[~2007-06-04 17:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=466A5811.6060303@raulete.net \
--to=adrian15@raulete.net \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.