The R Project SVN R

Rev

Rev 47442 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 47442 Rev 47602
Line 23... Line 23...
23
use Getopt::Long;
23
use Getopt::Long;
24
use R::Rdconv;
24
use R::Rdconv;
25
use R::Utils;
25
use R::Utils;
26
use R::Vars;
26
use R::Vars;
27
 
27
 
28
my $revision = ' $Rev: 47442 $ ';
28
my $revision = ' $Rev: 47602 $ ';
29
my $version;
29
my $version;
30
my $name;
30
my $name;
31
 
31
 
32
## switch on autoflushing for STDOUT.  We want this as we
32
## switch on autoflushing for STDOUT.  We want this as we
33
## write to both STDERR (warnings) and STDOUT.
33
## write to both STDERR (warnings) and STDOUT.
Line 42... Line 42...
42
## be lexical.  Argh.
42
## be lexical.  Argh.
43
$OSdir = $R::Vars::OSTYPE;
43
$OSdir = $R::Vars::OSTYPE;
44
## </NOTE>
44
## </NOTE>
45
 
45
 
46
my @knownoptions = ("debug|d", "type|t:s", "h|help", "v|version",
46
my @knownoptions = ("debug|d", "type|t:s", "h|help", "v|version",
47
		    "o|output:s", "os|OS=s" => \$OSdir, "encoding=s");
47
		    "o|output:s", "os|OS=s" => \$OSdir, "encoding=s",
-
 
48
		    "package=s", "version=s");
48
GetOptions (@knownoptions) || &usage();
49
GetOptions (@knownoptions) || &usage();
49
&R_version($name, $version) if $opt_v;
50
&R_version($name, $version) if $opt_v;
50
&usage() if $opt_h;
51
&usage() if $opt_h;
51
 
52
 
52
my $out = 0;
53
my $out = 0;
Line 60... Line 61...
60
    }
61
    }
61
}
62
}
62
$out = 0 if $out eq "-";
63
$out = 0 if $out eq "-";
63
my $enc = "unknown";
64
my $enc = "unknown";
64
$enc = $opt_encoding if $opt_encoding;
65
$enc = $opt_encoding if $opt_encoding;
-
 
66
my $pkg = "unknown";
-
 
67
$pkg = $opt_package if $opt_package;
-
 
68
my $ver = "";
-
 
69
$ver = $opt_version if $opt_version;
65
 
70
 
66
my %types_and_exts = ("txt", "",
71
my %types_and_exts = ("txt", "",
67
		      "html", ".html",
72
		      "html", ".html",
68
		      "latex", ".tex",
73
		      "latex", ".tex",
69
		      "example", ".R");
74
		      "example", ".R");
Line 73... Line 78...
73
foreach my $type (keys(%types_and_exts)) {
78
foreach my $type (keys(%types_and_exts)) {
74
    if($opt_type =~ /$type/i) {
79
    if($opt_type =~ /$type/i) {
75
	if(defined $opt_o && length($opt_o) == 0) {
80
	if(defined $opt_o && length($opt_o) == 0) {
76
	    $out .= $types_and_exts{$type};
81
	    $out .= $types_and_exts{$type};
77
	}
82
	}
78
	Rdconv($ARGV[0], $opt_type, $opt_debug, $out, "unknown", "", $enc);
83
	Rdconv($ARGV[0], $opt_type, $opt_debug, $out, $pkg, $ver, $enc);
79
	$opt_type_ok = 1;
84
	$opt_type_ok = 1;
80
	last;
85
	last;
81
    }
86
    }
82
}
87
}
83
 
88
 
Line 97... Line 102...
97
  -h, --help		print short help message and exit
102
  -h, --help		print short help message and exit
98
  -v, --version		print version info and exit
103
  -v, --version		print version info and exit
99
  -d, --debug		turn on debugging (increase verbosity)
104
  -d, --debug		turn on debugging (increase verbosity)
100
  -t, --type=TYPE	convert to format TYPE
105
  -t, --type=TYPE	convert to format TYPE
101
  --encoding=enc        use 'enc' as the default encoding
106
  --encoding=enc        use 'enc' as the default encoding
-
 
107
  --package=pkg         use 'pkg' as the package name
-
 
108
  --version=version     use 'version' as the package version
102
  -o, --output=OUT	use 'OUT' as the output file
109
  -o, --output=OUT	use 'OUT' as the output file
103
      --os=NAME		use OS subdir 'NAME' (unix or windows)
110
      --os=NAME		use OS subdir 'NAME' (unix or windows)
104
      --OS=NAME		the same as '--os'
111
      --OS=NAME		the same as '--os'
105
 
112
 
106
Possible format specifications are 'txt' (plain text), 'html', 'latex',
113
Possible format specifications are 'txt' (plain text), 'html', 'latex',