mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-13 14:56:29 -04:00
adds a description of the command line interface to the documentation
This commit is contained in:
parent
d544fa06d7
commit
57d66f06ea
@ -68,14 +68,14 @@ public abstract class ArgumentBase<T> {
|
|||||||
String s;
|
String s;
|
||||||
if (isBool())
|
if (isBool())
|
||||||
s = "-" + getName()
|
s = "-" + getName()
|
||||||
+ "("
|
+ "(def: "
|
||||||
+ get()
|
+ get()
|
||||||
+ ")";
|
+ ")";
|
||||||
else
|
else
|
||||||
s = "-" + getName()
|
s = "-" + getName()
|
||||||
+ " ["
|
+ " ["
|
||||||
+ get().getClass().getSimpleName()
|
+ get().getClass().getSimpleName()
|
||||||
+ "("
|
+ "(def: "
|
||||||
+ get()
|
+ get()
|
||||||
+ ")]";
|
+ ")]";
|
||||||
|
|
||||||
|
@ -7,7 +7,9 @@ package de.neemann.digital.cli.cli;
|
|||||||
|
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.Writer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -65,7 +67,32 @@ public abstract class BasicCommand extends NamedCommand {
|
|||||||
out.print(prefix + " ");
|
out.print(prefix + " ");
|
||||||
printString(out, prefix + " ", a.getDescription(getName()));
|
printString(out, prefix + " ", a.getDescription(getName()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printXMLDescription(Writer w) throws IOException {
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.append(getName());
|
||||||
|
for (ArgumentBase<?> a : arguments) {
|
||||||
|
w.append(" ");
|
||||||
|
w.append(a.toString());
|
||||||
|
}
|
||||||
|
w.append(":");
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.write(Lang.get("cli_help_" + getName()));
|
||||||
|
w.write("</indent>\n");
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.write(Lang.get("cli_options"));
|
||||||
|
for (ArgumentBase<?> a : arguments) {
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.write(a.toStringDef());
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.write(a.getDescription(getName()));
|
||||||
|
w.write("</indent>\n");
|
||||||
|
w.write("</indent>\n");
|
||||||
|
}
|
||||||
|
w.write("</indent>\n");
|
||||||
|
w.write("</indent>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void printString(PrintStream out, String prefix, String message) {
|
void printString(PrintStream out, String prefix, String message) {
|
||||||
|
@ -5,27 +5,38 @@
|
|||||||
*/
|
*/
|
||||||
package de.neemann.digital.cli.cli;
|
package de.neemann.digital.cli.cli;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.Writer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A cli command
|
* A cli command
|
||||||
*/
|
*/
|
||||||
public interface CLICommand {
|
public interface CLICommand {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the command
|
||||||
|
*
|
||||||
|
* @param args the arguments
|
||||||
|
* @throws CLIException CLIException
|
||||||
|
*/
|
||||||
|
void execute(String[] args) throws CLIException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the description
|
* Prints the description
|
||||||
*
|
*
|
||||||
* @param out the pront stream
|
* @param out the print stream
|
||||||
* @param prefix the prefex string which should
|
* @param prefix the prefex string which should
|
||||||
* printed at the beginning of each line
|
* printed at the beginning of each line
|
||||||
*/
|
*/
|
||||||
void printDescription(PrintStream out, String prefix);
|
void printDescription(PrintStream out, String prefix);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Esecuted the command
|
* Prints the description in xml format
|
||||||
*
|
*
|
||||||
* @param args the arguments
|
* @param w the writer to write to
|
||||||
* @throws CLIException CLIException
|
* @throws IOException IOException
|
||||||
*/
|
*/
|
||||||
void execute(String[] args) throws CLIException;
|
void printXMLDescription(Writer w) throws IOException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,9 @@ package de.neemann.digital.cli.cli;
|
|||||||
|
|
||||||
import de.neemann.digital.lang.Lang;
|
import de.neemann.digital.lang.Lang;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
import java.io.Writer;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
@ -58,6 +60,15 @@ public class Muxer extends NamedCommand {
|
|||||||
c.printDescription(out, prefix + " ");
|
c.printDescription(out, prefix + " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void printXMLDescription(Writer w) throws IOException {
|
||||||
|
w.write("<indent>\n");
|
||||||
|
w.write(getName());
|
||||||
|
for (CLICommand c : commands.values())
|
||||||
|
c.printXMLDescription(w);
|
||||||
|
w.write("</indent>\n");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(String[] args) throws CLIException {
|
public void execute(String[] args) throws CLIException {
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
|
@ -1541,6 +1541,7 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
|||||||
<string name="lib_ram">RAM</string>
|
<string name="lib_ram">RAM</string>
|
||||||
<string name="lib_eeprom">EEPROM</string>
|
<string name="lib_eeprom">EEPROM</string>
|
||||||
|
|
||||||
|
<string name="cli_cli">Steuerung per Kommandozeile</string>
|
||||||
<string name="cli_nonOptionalArgumentMissing_N">Es fehlt das nicht optionale Argument {0}.</string>
|
<string name="cli_nonOptionalArgumentMissing_N">Es fehlt das nicht optionale Argument {0}.</string>
|
||||||
<string name="cli_notABool_N">Der Wert {0} ist kein bool.</string>
|
<string name="cli_notABool_N">Der Wert {0} ist kein bool.</string>
|
||||||
<string name="cli_notANumber_N">Der Wert {0} ist keine Zahl.</string>
|
<string name="cli_notANumber_N">Der Wert {0} ist keine Zahl.</string>
|
||||||
@ -1572,7 +1573,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
|||||||
Aufgeführt sind alle verwendeten Komponenten.
|
Aufgeführt sind alle verwendeten Komponenten.
|
||||||
</string>
|
</string>
|
||||||
<string name="cli_help_stats_dig">Name der Schaltung.</string>
|
<string name="cli_help_stats_dig">Name der Schaltung.</string>
|
||||||
<string name="cli_help_stats_csv">Name der Ausgabedatei.</string>
|
<string name="cli_help_stats_csv">Name der Ausgabedatei.
|
||||||
|
Wenn diese Option fehlt, erfolgt eine Ausgabe auf die Konsole.
|
||||||
|
</string>
|
||||||
<string name="cli_errorCreatingStats">Fehler bei der Erzeugung der CSV Datei!</string>
|
<string name="cli_errorCreatingStats">Fehler bei der Erzeugung der CSV Datei!</string>
|
||||||
|
|
||||||
<string name="menu_window">Fenster</string>
|
<string name="menu_window">Fenster</string>
|
||||||
|
@ -1505,6 +1505,7 @@
|
|||||||
<string name="lib_ram">RAM</string>
|
<string name="lib_ram">RAM</string>
|
||||||
<string name="lib_eeprom">EEPROM</string>
|
<string name="lib_eeprom">EEPROM</string>
|
||||||
|
|
||||||
|
<string name="cli_cli">Command Line Interface</string>
|
||||||
<string name="cli_nonOptionalArgumentMissing_N">The non-optional argument {0} is missing.</string>
|
<string name="cli_nonOptionalArgumentMissing_N">The non-optional argument {0} is missing.</string>
|
||||||
<string name="cli_notABool_N">The value {0} is no bool.</string>
|
<string name="cli_notABool_N">The value {0} is no bool.</string>
|
||||||
<string name="cli_notANumber_N">The value {0} is not a number.</string>
|
<string name="cli_notANumber_N">The value {0} is not a number.</string>
|
||||||
@ -1534,7 +1535,9 @@
|
|||||||
All components used are listed in the CSV file.
|
All components used are listed in the CSV file.
|
||||||
</string>
|
</string>
|
||||||
<string name="cli_help_stats_dig">File name of the circuit.</string>
|
<string name="cli_help_stats_dig">File name of the circuit.</string>
|
||||||
<string name="cli_help_stats_csv">Name of the csv file to be created.</string>
|
<string name="cli_help_stats_csv">Name of the csv file to be created.
|
||||||
|
If this option is missing, the table is written to stdout.
|
||||||
|
</string>
|
||||||
<string name="cli_errorCreatingStats">Error while creating the stats file!</string>
|
<string name="cli_errorCreatingStats">Error while creating the stats file!</string>
|
||||||
|
|
||||||
<string name="menu_window">Windows</string>
|
<string name="menu_window">Windows</string>
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package de.neemann.digital.docu;
|
package de.neemann.digital.docu;
|
||||||
|
|
||||||
|
import de.neemann.digital.cli.Main;
|
||||||
import de.neemann.digital.core.NodeException;
|
import de.neemann.digital.core.NodeException;
|
||||||
import de.neemann.digital.core.element.*;
|
import de.neemann.digital.core.element.*;
|
||||||
import de.neemann.digital.draw.elements.PinException;
|
import de.neemann.digital.draw.elements.PinException;
|
||||||
@ -89,6 +90,8 @@ public class DocuTest extends TestCase {
|
|||||||
w.append(" </circuit>\n");
|
w.append(" </circuit>\n");
|
||||||
w.append(" </settings>\n");
|
w.append(" </settings>\n");
|
||||||
|
|
||||||
|
writeCLIDescription(w);
|
||||||
|
|
||||||
ElementLibrary library = new ElementLibrary();
|
ElementLibrary library = new ElementLibrary();
|
||||||
ShapeFactory shapeFactory = new ShapeFactory(library, !language.equals("de"));
|
ShapeFactory shapeFactory = new ShapeFactory(library, !language.equals("de"));
|
||||||
String actPath = null;
|
String actPath = null;
|
||||||
@ -139,6 +142,12 @@ public class DocuTest extends TestCase {
|
|||||||
w.append("</root>");
|
w.append("</root>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void writeCLIDescription(Writer w) throws IOException {
|
||||||
|
w.append(" <cli heading=\"").append(Lang.get("cli_cli")).append("\">\n");
|
||||||
|
new Main().printXMLDescription(w);
|
||||||
|
w.append(" </cli>\n");
|
||||||
|
}
|
||||||
|
|
||||||
private void writeAttributes(Writer w, List<Key> keyList) throws IOException {
|
private void writeAttributes(Writer w, List<Key> keyList) throws IOException {
|
||||||
w.append(" <attributes name=\"").append(Lang.get("elem_Help_attributes")).append("\">\n");
|
w.append(" <attributes name=\"").append(Lang.get("elem_Help_attributes")).append("\">\n");
|
||||||
for (Key k : keyList) {
|
for (Key k : keyList) {
|
||||||
|
@ -78,43 +78,86 @@
|
|||||||
<fo:block page-break-before="always" margin-bottom="5mm" font-size="18pt" font-weight="bold">
|
<fo:block page-break-before="always" margin-bottom="5mm" font-size="18pt" font-weight="bold">
|
||||||
<xsl:value-of select="@toc"/>
|
<xsl:value-of select="@toc"/>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<!-- table of contents -->
|
<!-- table of contents -->
|
||||||
<fo:block margin-bottom="2mm" font-weight="bold">
|
<fo:block margin-bottom="2mm" font-weight="bold">
|
||||||
A <fo:inline padding-left="1mm"><xsl:value-of select="@general"/></fo:inline>
|
A
|
||||||
|
<fo:inline padding-left="1mm">
|
||||||
|
<xsl:value-of select="@general"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="document(@static)/*" mode="toc"/>
|
<xsl:apply-templates select="document(@static)/*" mode="toc"/>
|
||||||
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
||||||
<fo:basic-link show-destination="replace" internal-destination="chap_settings">
|
<fo:basic-link show-destination="replace" internal-destination="chap_settings">
|
||||||
B <fo:inline padding-left="2mm"><xsl:value-of select="settings/@name"/></fo:inline>
|
B
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="settings/@name"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:basic-link>
|
</fo:basic-link>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
||||||
C <fo:inline padding-left="2mm"><xsl:value-of select="@components"/></fo:inline>
|
<fo:basic-link show-destination="replace" internal-destination="chap_cli">
|
||||||
|
C
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="cli/@heading"/>
|
||||||
|
</fo:inline>
|
||||||
|
</fo:basic-link>
|
||||||
|
</fo:block>
|
||||||
|
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
||||||
|
D
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="@components"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="lib" mode="toc"/>
|
<xsl:apply-templates select="lib" mode="toc"/>
|
||||||
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
<fo:block margin-top="2mm" margin-bottom="2mm" font-weight="bold">
|
||||||
<fo:basic-link show-destination="replace" internal-destination="chap_library">
|
<fo:basic-link show-destination="replace" internal-destination="chap_library">
|
||||||
D <fo:inline padding-left="2mm"><xsl:value-of select="@lib"/></fo:inline>
|
E
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="@lib"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:basic-link>
|
</fo:basic-link>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<fo:block page-break-before="always"/>
|
<fo:block page-break-before="always"/>
|
||||||
<!-- the content -->
|
<!-- the content -->
|
||||||
<fo:block margin-top="4mm" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
<fo:block margin-top="4mm" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
||||||
A <fo:inline padding-left="2mm"><xsl:value-of select="@general"/></fo:inline>
|
A
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="@general"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="document(@static)/*" mode="full"/>
|
<xsl:apply-templates select="document(@static)/*" mode="full"/>
|
||||||
|
|
||||||
<fo:block page-break-before="always" margin-top="4mm" margin-bottom="4mm" font-size="16pt" font-weight="bold" id="chap_settings">
|
<fo:block page-break-before="always" margin-top="4mm" margin-bottom="4mm" font-size="16pt"
|
||||||
B <fo:inline padding-left="2mm"><xsl:value-of select="settings/@name"/></fo:inline>
|
font-weight="bold" id="chap_settings">
|
||||||
|
B
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="settings/@name"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="settings" mode="full"/>
|
<xsl:apply-templates select="settings" mode="full"/>
|
||||||
|
|
||||||
|
<fo:block page-break-before="always" margin-top="4mm" margin-bottom="4mm" font-size="16pt"
|
||||||
|
font-weight="bold" id="chap_cli">
|
||||||
|
C
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="cli/@heading"/>
|
||||||
|
</fo:inline>
|
||||||
|
</fo:block>
|
||||||
|
<xsl:apply-templates select="cli" mode="full"/>
|
||||||
|
|
||||||
<fo:block page-break-before="always" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
<fo:block page-break-before="always" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
||||||
C <fo:inline padding-left="2mm"><xsl:value-of select="@components"/></fo:inline>
|
D
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="@components"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="lib" mode="full"/>
|
<xsl:apply-templates select="lib" mode="full"/>
|
||||||
<fo:block page-break-before="always" margin-bottom="4mm" font-size="16pt" font-weight="bold" id="chap_library">
|
<fo:block page-break-before="always" margin-bottom="4mm" font-size="16pt" font-weight="bold"
|
||||||
D <fo:inline padding-left="2mm"><xsl:value-of select="@lib"/></fo:inline>
|
id="chap_library">
|
||||||
|
E
|
||||||
|
<fo:inline padding-left="2mm">
|
||||||
|
<xsl:value-of select="@lib"/>
|
||||||
|
</fo:inline>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="document(@library)/*"/>
|
<xsl:apply-templates select="document(@library)/*"/>
|
||||||
<fo:block id="LastPage"/>
|
<fo:block id="LastPage"/>
|
||||||
@ -294,14 +337,25 @@
|
|||||||
<xsl:apply-templates select="circuit/attributes"/>
|
<xsl:apply-templates select="circuit/attributes"/>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="cli" mode="full">
|
||||||
|
<xsl:apply-templates select="indent"/>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
<xsl:template match="indent">
|
||||||
|
<fo:block margin-left="4mm" start-indent="2mm" margin-top="2mm" margin-bottom="2mm">
|
||||||
|
<xsl:apply-templates/>
|
||||||
|
</fo:block>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="lib" mode="full">
|
<xsl:template match="lib" mode="full">
|
||||||
<fo:block page-break-after="avoid" margin-top="4mm" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
<fo:block page-break-after="avoid" margin-top="4mm" margin-bottom="4mm" font-size="16pt" font-weight="bold">
|
||||||
<xsl:value-of select="position()"/>. <xsl:value-of select="@name"/>
|
<xsl:value-of select="position()"/>.
|
||||||
|
<xsl:value-of select="@name"/>
|
||||||
</fo:block>
|
</fo:block>
|
||||||
<xsl:apply-templates select="element" mode="full">
|
<xsl:apply-templates select="element" mode="full">
|
||||||
<xsl:with-param name="number" select="position()"/>
|
<xsl:with-param name="number" select="position()"/>
|
||||||
</xsl:apply-templates>
|
</xsl:apply-templates>
|
||||||
</xsl:template>
|
</xsl:template>
|
||||||
|
|
||||||
<xsl:template match="element" mode="full">
|
<xsl:template match="element" mode="full">
|
||||||
<xsl:param name="number" />
|
<xsl:param name="number" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user