]> git.lyx.org Git - features.git/commitdiff
tex2lyx : More descriptive --help message and implement --version (#6827).
authorJulien Rioux <jrioux@lyx.org>
Wed, 19 Oct 2011 14:53:01 +0000 (14:53 +0000)
committerJulien Rioux <jrioux@lyx.org>
Wed, 19 Oct 2011 14:53:01 +0000 (14:53 +0000)
Also allow -h and -v command-line options, manpage update.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@39887 a592a061-630c-0410-9148-cb99ea01b6c8

development/cmake/src/tex2lyx/CMakeLists.txt
development/scons/scons_manifest.py
src/tex2lyx/Makefile.am
src/tex2lyx/tex2lyx.1in
src/tex2lyx/tex2lyx.cpp
status.20x

index 7fbd12f7f65901b399504f0694c4f09f45992beb..5e33cdfc634a54aa4f34fb148a45c6420dcf78bb 100644 (file)
@@ -13,9 +13,9 @@ set(LINKED_sources ${TOP_SRC_DIR}/src/lengthcommon.cpp)
 set(LINKED_headers)
 
 foreach(_src insets/InsetLayout Color Counters
-       Encoding FloatList Floating
+       Encoding FloatList Floating FontInfo
        Layout LayoutFile LayoutModuleList Lexer ModuleList TextClass
-       FontInfo Spacing)
+       Spacing version)
        list(APPEND LINKED_sources ${TOP_SRC_DIR}/src/${_src}.cpp)
        list(APPEND LINKED_headers ${TOP_SRC_DIR}/src/${_src}.h)
 endforeach(_src)
index d4337f8f3e70e75b6cc48d117d6bb1030566e96e..af9e32298e1411695d6774ecc1355818d133bcf6 100644 (file)
@@ -635,6 +635,7 @@ src_tex2lyx_copied_files = Split('''
     ModuleList.cpp
     Spacing.cpp
     TextClass.cpp
+    version.cpp
     insets/InsetLayout.cpp
 ''')
 
index 93b1c7cb9a76c89eeb5c58c30430350ddd0ce718..8020d02d3420e31d3d0ac03332851a8ad69245f4 100644 (file)
@@ -44,7 +44,8 @@ LINKED_FILES = \
        ../ModuleList.cpp \
        ../Spacing.cpp \
        ../TextClass.cpp \
-       ../TextClass.h
+       ../TextClass.h \
+       ../version.cpp
 
 BUILT_SOURCES = $(PCH_FILE)
 
index 8ff02218ffe37a5b0d9646d0658cf6d0fac880ab..316ec0ce2021de1e14251b097612f0014c5ce8a5 100644 (file)
@@ -83,6 +83,9 @@ named \fIfoo.lyx.lyx\fR, and the re-exported file will be named
 .TP
 .BI \-help
 Help. Print out usage information and quit.
+.TP
+.BI \-version
+Print out the version number and build information and quit.
 .SH "DESCRIPTION"
 .SS "Introduction"
 \fBtex2lyx\fR will create a LyX file with the specified name (or
index 8d5e858885e31d27b29ed75a7259c3534fa4c4e5..25f5955a68f3d3c46ed434d7f10780dffd20ce25 100644 (file)
@@ -11,6 +11,7 @@
 // {[(
 
 #include <config.h>
+#include <version.h>
 
 #include "tex2lyx.h"
 
@@ -464,13 +465,33 @@ int parse_help(string const &, string const &)
                "\t-n                 translate a noweb (aka literate programming) file.\n"
                "\t-roundtrip         re-export created .lyx file infile.lyx.lyx to infile.lyx.tex.\n"
                "\t-s syntaxfile      read additional syntax file.\n"
-               "\t-sysdir dir        Set system directory to DIR.\n"
-               "\t-userdir DIR       Set user directory to DIR."
+               "\t-sysdir SYSDIR     Set system directory to SYSDIR.\n"
+               "\t                   Default: " << package().system_support() << "\n"
+               "\t-userdir USERDIR   Set user directory to USERDIR.\n"
+               "\t                   Default: " << package().user_support() << "\n"
+               "\t-version           Summarize version and build info.\n"
+               "Paths:\n"
+               "\tThe program searches for the files \"encodings\", \"lyxmodules.lst\",\n"
+               "\t\"textclass.lst\", \"syntax.default\", and \"unicodesymbols\", first in\n"
+               "\t\"USERDIR\", then in \"SYSDIR\". The subdirectories \"USERDIR/layouts\"\n"
+               "\tand \"SYSDIR/layouts\" are searched for layout and module files.\n"
+               "Check the tex2lyx man page for more details."
             << endl;
        exit(error_code);
 }
 
 
+int parse_version(string const &, string const &)
+{
+       lyxerr << "tex2lyx " << lyx_version
+              << " (" << lyx_release_date << ")" << endl;
+       lyxerr << "Built on " << __DATE__ << ", " << __TIME__ << endl;
+
+       lyxerr << lyx_version_info << endl;
+       exit(error_code);
+}
+
+
 void error_message(string const & message)
 {
        cerr << "tex2lyx: " << message << "\n\n";
@@ -555,12 +576,16 @@ void easyParse(int & argc, char * argv[])
 {
        map<string, cmd_helper> cmdmap;
 
+       cmdmap["-h"] = parse_help;
+       cmdmap["-help"] = parse_help;
+       cmdmap["--help"] = parse_help;
+       cmdmap["-v"] = parse_version;
+       cmdmap["-version"] = parse_version;
+       cmdmap["--version"] = parse_version;
        cmdmap["-c"] = parse_class;
        cmdmap["-e"] = parse_encoding;
        cmdmap["-f"] = parse_force;
        cmdmap["-s"] = parse_syntaxfile;
-       cmdmap["-help"] = parse_help;
-       cmdmap["--help"] = parse_help;
        cmdmap["-n"] = parse_noweb;
        cmdmap["-sysdir"] = parse_sysdir;
        cmdmap["-userdir"] = parse_userdir;
@@ -766,6 +791,16 @@ int main(int argc, char * argv[])
 
        os::init(argc, argv);
 
+       try {
+               init_package(internal_path(os::utf8_argv(0)), string(), string(),
+                            top_build_dir_is_two_levels_up);
+       } catch (ExceptionMessage const & message) {
+               cerr << to_utf8(message.title_) << ":\n"
+                    << to_utf8(message.details_) << endl;
+               if (message.type_ == ErrorException)
+                       return EXIT_FAILURE;
+       }
+
        easyParse(argc, argv);
 
        if (argc <= 1) 
index cbe43054554243ed25c271fb709fa5260c38af36..7d435e7e7145ae4a3205ccbca1b26f8b7e281064 100644 (file)
@@ -53,6 +53,11 @@ What's new
   text which is not explicitly marked in a different language, irrespective
   of the multilingual status, except for LTR<=>RTL changes.
 
+- Augmented the tex2lyx -help message with the default pathes (bug 6827).
+
+- New command-line switch -v (-version) for tex2lyx showing build information
+  and version number (bug 6827).
+
 
 * DOCUMENTATION AND LOCALIZATION