# HG changeset patch # User Rob Landley # Date 1400764615 18000 # Node ID 2b89b13df19eefa21d4eac3af6f9e9aaa38934be # Parent 1253f0c3dd53eeabec7f4a9ff1e27c3df9f1b21c Update docs for example and pending directories. diff -r 1253f0c3dd53 -r 2b89b13df19e www/code.html --- a/www/code.html Wed May 21 07:57:48 2014 -0500 +++ b/www/code.html Thu May 22 08:16:55 2014 -0500 @@ -112,8 +112,8 @@
  • lib/dirtree.c
  • The toys directory contains the C files implementating -each command. Currently it contains three subdirectories: -posix, lsb, and other.
  • +each command. Currently it contains five subdirectories categorizing the +commands: posix, lsb, other, example, and pending.
  • The scripts directory contains the build and test infrastructure.
  • The kconfig directory contains the configuration @@ -130,27 +130,41 @@ formatted comments and macros in the C file. (See the description of the "generated" directory for details.)

    -

    Currently there are three subdirectories under "toys", one for commands +

    Currently there are five subdirectories under "toys", one for commands defined by the POSIX standard, one for commands defined by the Linux Standard -Base, and one for all other commands. (This is just for developer convenience -sorting them, the directories are otherwise functionally identical.)

    +Base, an "other" directory for commands not covered by an obvious standard, +a directory of example commands (templates to use when starting new commands), +and a "pending" directory of commands that need further review/cleanup +before moving to one of the other directories (run these at your own risk, +cleanup patches welcome). +These directories are just for developer convenience sorting the commands, +the directories are otherwise functionally identical. To add a new category, +create the appropriate directory with a README file in it whose first line +is the description menuconfig should use for the directory.)

    -

    An easy way to start a new command is copy the file "toys/other/hello.c" to -the name of the new command, and modify this copy to implement the new command. -This file is an example command meant to be used as a "skeleton" for -new commands (more or less by turning every instance of "hello" into the +

    An easy way to start a new command is copy the file "toys/example/hello.c" +to the name of the new command, and modify this copy to implement the new +command (more or less by turning every instance of "hello" into the name of your command, updating the command line arguments, globals, and -help data, and then filling out its "main" function with code that does -something interesting). It provides examples of all the build infrastructure -(including optional elements like command line argument parsing and global -variables that a "hello world" program doesn't strictly need).

    +help data, and then filling out its "main" function with code that does +something interesting).

    + +

    You could also start with "toys/example/skeleton.c", which provides a lot +more example code (showing several variants of command line option +parsing, how to implement multiple commands in the same file, and so on). +But usually it's just more stuff to delete.

    Here's a checklist of steps to turn hello.c into another command:

    Headers.