001package org.unix4j.unix;
002
003import org.unix4j.command.CommandInterface;
004
005import org.unix4j.unix.cat.CatFactory;
006import org.unix4j.unix.cat.CatOption;
007import org.unix4j.unix.cat.CatOptions;
008import org.unix4j.unix.cat.CatOptionSets;
009
010/**
011 * Non-instantiable module with inner types making up the <b>cat</b> command.
012 * <p>
013 * <b>NAME</b>
014 * <p>
015 * cat - concatenate and print files 
016 * <p>
017 * <b>SYNOPSIS</b>
018 * <p>
019 * <table>
020 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat}</td></tr>
021 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat <args>}</td></tr>
022 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat <files>}</td></tr>
023 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat <inputs>}</td></tr>
024 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat [-bns]}</td></tr>
025 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat [-bns] <files>}</td></tr>
026 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat [-bns] <paths>}</td></tr>
027 * <tr><td width="10px"></td><td nowrap="nowrap">{@code cat [-bns] <inputs>}</td></tr>
028 * </table>
029 * <p>
030 * See {@link Interface} for the corresponding command signature methods.
031 * <p>
032 * <b>DESCRIPTION</b>
033 * <p>
034 *  <p> The cat utility reads files sequentially, writing them to the standard  output. The file operands are processed in command-argument order. If no        file argument is specified, cat reads from the standard input. </p>
035 * 
036 * <p>
037 * <b>Options</b>
038 * <p>
039 * The following options are supported:
040 * <p>
041 * <table>
042 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -b}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --numberNonBlankLines}</td><td>&nbsp;</td><td>Number the non-blank output lines, starting at 1.</td></tr>
043 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -n}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --numberLines}</td><td>&nbsp;</td><td>Number the output lines, starting at 1.</td></tr>
044 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -s}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --squeezeEmptyLines}</td><td>&nbsp;</td><td>Squeeze multiple adjacent empty lines, causing the output to be 
045                        single spaced.</td></tr>
046 * </table>
047 * <p>
048 * <b>OPERANDS</b>
049 * <p>
050 * The following operands are supported:
051 * <p>
052 * <table>
053 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <files>}</td><td>&nbsp;:&nbsp;</td><td nowrap="nowrap">{@code java.io.File...}</td><td>&nbsp;</td><td>The input files to be printed; relative paths are not resolved (use 
054                        the string path argument to enable relative path resolving based on 
055                        the current working directory).</td></tr>
056 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <paths>}</td><td>&nbsp;:&nbsp;</td><td nowrap="nowrap">{@code String...}</td><td>&nbsp;</td><td>Path names of the input files to be printed; wildcards * and ? are
057                        supported; relative paths are resolved on the basis of the current 
058                        working directory.</td></tr>
059 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <inputs>}</td><td>&nbsp;:&nbsp;</td><td nowrap="nowrap">{@code org.unix4j.io.Input...}</td><td>&nbsp;</td><td>The inputs to be printed.</td></tr>
060 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <args>}</td><td>&nbsp;:&nbsp;</td><td nowrap="nowrap">{@code String...}</td><td>&nbsp;</td><td>String arguments defining the options and file operands for the 
061                        command. Options can be specified by acronym (with a leading dash 
062                        "-") or by long name (with two leading dashes "--"). File arguments 
063                        are expanded if wildcards are used.</td></tr>
064 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code <options>}</td><td>&nbsp;:&nbsp;</td><td nowrap="nowrap">{@code CatOptions}</td><td>&nbsp;</td><td>Options for the cat command.</td></tr>
065 * </table>
066 */
067public final class Cat {
068        /**
069         * The "cat" command name.
070         */
071        public static final String NAME = "cat";
072
073        /**
074         * Interface defining all method signatures for the "cat" command.
075         * 
076         * @param <R>
077         *            the generic return type for all command signature methods
078         *            to support different implementor types; the methods of a 
079         *            command factory for instance returns a command instance; 
080         *            command builders can also implement this interface, but their
081         *            methods return the builder itself enabling for chained method
082         *            invocation to create joined commands
083         */
084        public static interface Interface<R> extends CommandInterface<R> {
085                /**
086                 * Reads the lines from the standard input and writes them to the
087                        standard output.
088                 *
089                 * @return the generic type {@code <R>} defined by the implementing class;
090                 *         the command itself returns no value and writes its result to the
091                 *         standard output; see class level parameter comments for more 
092                 *         details
093                 */
094                R cat();
095                /**
096                 * Reads the lines from files specified as arguments and writes them to
097                        the standard output. Options can be specified by acronym (with a
098                        leading dash "-") or by long name (with two leading dashes "--"). 
099                        File arguments are expanded if wildcards are used. All file 
100                        arguments are processed in command-argument order.
101                 *
102                 * @param args String arguments defining the options and file operands for the 
103                        command. Options can be specified by acronym (with a leading dash 
104                        "-") or by long name (with two leading dashes "--"). File arguments 
105                        are expanded if wildcards are used.
106                 * @return the generic type {@code <R>} defined by the implementing class;
107                 *         the command itself returns no value and writes its result to the
108                 *         standard output; see class level parameter comments for more 
109                 *         details
110                 */
111                R cat(String... args);
112                /**
113                 * Reads the lines from the specified files and writes them to the
114                        standard output. The files are processed in command-argument order.
115                 *
116                 * @param files The input files to be printed; relative paths are not resolved (use 
117                        the string path argument to enable relative path resolving based on 
118                        the current working directory).
119                 * @return the generic type {@code <R>} defined by the implementing class;
120                 *         the command itself returns no value and writes its result to the
121                 *         standard output; see class level parameter comments for more 
122                 *         details
123                 */
124                R cat(java.io.File... files);
125                /**
126                 * Reads the lines from the specified inputs and writes them to the
127                        standard output. The inputs are processed in command-argument order.
128                 *
129                 * @param inputs The inputs to be printed.
130                 * @return the generic type {@code <R>} defined by the implementing class;
131                 *         the command itself returns no value and writes its result to the
132                 *         standard output; see class level parameter comments for more 
133                 *         details
134                 */
135                R cat(org.unix4j.io.Input... inputs);
136                /**
137                 * Reads the lines from the standard input and writes them to the
138                        standard output; the given options define the details of the output
139                        format.
140                 *
141                 * @param options Options for the cat command.
142                 * @return the generic type {@code <R>} defined by the implementing class;
143                 *         the command itself returns no value and writes its result to the
144                 *         standard output; see class level parameter comments for more 
145                 *         details
146                 */
147                R cat(CatOptions options);
148                /**
149                 * Reads the lines from the specified files and writes them to the
150                        standard output; the given options define the details of the output
151                        format. The files are processed in command-argument order.
152                 *
153                 * @param options Options for the cat command.
154                 * @param files The input files to be printed; relative paths are not resolved (use 
155                        the string path argument to enable relative path resolving based on 
156                        the current working directory).
157                 * @return the generic type {@code <R>} defined by the implementing class;
158                 *         the command itself returns no value and writes its result to the
159                 *         standard output; see class level parameter comments for more 
160                 *         details
161                 */
162                R cat(CatOptions options, java.io.File... files);
163                /**
164                 * Reads the lines from the specified files and writes them to the
165                        standard output; the given options define the details of the output
166                        format. The path arguments are expanded if wildcards are used and
167                        processed in command-argument order.
168                 *
169                 * @param options Options for the cat command.
170                 * @param paths Path names of the input files to be printed; wildcards * and ? are
171                        supported; relative paths are resolved on the basis of the current 
172                        working directory.
173                 * @return the generic type {@code <R>} defined by the implementing class;
174                 *         the command itself returns no value and writes its result to the
175                 *         standard output; see class level parameter comments for more 
176                 *         details
177                 */
178                R cat(CatOptions options, String... paths);
179                /**
180                 * Reads the lines from the specified inputs and writes them to the
181                        standard output; the given options define the details of the output
182                        format. The inputs are processed in command-argument order.
183                 *
184                 * @param options Options for the cat command.
185                 * @param inputs The inputs to be printed.
186                 * @return the generic type {@code <R>} defined by the implementing class;
187                 *         the command itself returns no value and writes its result to the
188                 *         standard output; see class level parameter comments for more 
189                 *         details
190                 */
191                R cat(CatOptions options, org.unix4j.io.Input... inputs);
192        }
193
194        /**
195         * Options for the "cat" command: {@link CatOption#numberNonBlankLines b}, {@link CatOption#numberLines n}, {@link CatOption#squeezeEmptyLines s}.
196         * <p> 
197 * <table>
198 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -b}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --numberNonBlankLines}</td><td>&nbsp;</td><td>Number the non-blank output lines, starting at 1.</td></tr>
199 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -n}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --numberLines}</td><td>&nbsp;</td><td>Number the output lines, starting at 1.</td></tr>
200 * <tr valign="top"><td width="10px"></td><td nowrap="nowrap">{@code -s}</td><td>&nbsp;&nbsp;</td><td nowrap="nowrap">{@code --squeezeEmptyLines}</td><td>&nbsp;</td><td>Squeeze multiple adjacent empty lines, causing the output to be 
201                        single spaced.</td></tr>
202 * </table>
203         */
204        public static final CatOptionSets Options = CatOptionSets.INSTANCE;
205
206        /**
207         * Singleton {@link CatFactory factory} instance for the "cat" command.
208         */
209        public static final CatFactory Factory = CatFactory.INSTANCE;
210
211        // no instances
212        private Cat() {
213                super();
214        }
215}