File: FIRSTSTEP.ja.html

package info (click to toggle)
liboptparse-ruby 0.8.4-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 428 kB
  • ctags: 644
  • sloc: ruby: 1,819; makefile: 47
file content (87 lines) | stat: -rw-r--r-- 4,826 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?xml version="1.0" encoding="euc-jp" ?>
<!DOCTYPE html 
  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FIRSTSTEP.ja</title>
<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />
<link href="rd.css" type="text/css" rel="stylesheet"/>
</head>
<body>
<h1><a name="label:0" id="label:0">Ϥ</a></h1><!-- RDLabel: "Ϥ" -->
<p>OptionParser ϥޥɥ饤ΥץβϤñ˹ԤΥ饹Ǥ롣</p>
<p>ޥɥ饤βϤȤΤϡɤʥġǤۤȤƱѥɬפˤʤ롣
ƤˤϤĤήΤ褦ʤΤ롣</p>
<h2><a name="label:1" id="label:1">ûĹץ</a></h2><!-- RDLabel: "ûĹץ" -->
<p>Unix ΥġΥץ󥹥åϡŪ<code>-</code> ³ѻʸǻꤵ롣
̾ʣΤΤ³ƻꤹ뤳ȤǤ롣
㤨<code>ls</code>ޥɤʤ顢ΣĤƱư򤹤롣</p>
<pre>ls -l -a

ls -la</pre>
<p>ޤǶ GNU tools ʤɤ <code>--</code> ǻϤޤĹ̾ΥåȤ롣</p>
<pre>ls --all</pre>
<p>OptionParserϤξη򥵥ݡȤ롣
󺮤ƻȤȤǽ</p>
<h1><a name="label:2" id="label:2">Ȥ</a></h1><!-- RDLabel: "Ȥ" -->
<h2><a name="label:3" id="label:3">ñʻȤ</a></h2><!-- RDLabel: "ñʻȤ" -->
<pre>require 'optparse'
ARGV.options {|q|
  q.def_option('--help', 'show this message') {puts q; exit(0)}	# &lt;- (1)
  q.parse!
} or exit(1)</pre>
<p>ǡ<kbd>--help</kbd><kbd>--hELp</kbd><kbd>--hEl</kbd><kbd>--HE</kbd>
<kbd>--h</kbd> ʤɤĹΥå<a name="footmark:1" id="footmark:1" href="#foottext:1"><sup><small>*1</small></sup></a>˲äơ<kbd>-h</kbd>ȤûΥץ󥹥åȤ褦ˤʤ롣
OptionParserǤϡûΥåդʤä硢ưŪĹξάȤߤʤ</p>
<p>ΥץȤФ<kbd>--help</kbd>åꤹȡ(1)Υ֥å¹Ԥ롣
<code>puts q</code>ȤΤϡǤ륪ץΰɽ뤳Ȥ̣롣</p>
<p>ʤåꤵ줿Ȥˤϡ顼å<code>STDERR</code>
ɽƽλ1ǽλ롣</p>
<p><a name="footmark:2" id="footmark:2" href="#foottext:2"><sup><small>*2</small></sup></a></p>
<h2><a name="label:4" id="label:4">ե饰</a></h2><!-- RDLabel: "ե饰" -->
<p>̾ץ󥹥åꤵ줿ϲ餫Υե饰<a name="footmark:3" id="footmark:3" href="#foottext:3"><sup><small>*3</small></sup></a>ʤɤ򥻥åȤƤơȤǻȤǤ褦ˤ롣</p>
<pre>require 'optparse'
$verbose = false
ARGV.options {|q|
  q.def_option('-v', '--verbose', 'run verbosely') {$verbose = true}
  q.parse!
} or exit(1)
puts "verbose=#$verbose"</pre>
<p>ǡ<kbd>--verbose</kbd><kbd>-V</kbd>ʤɤȻꤵС(1)Υ֥å¹Ԥ
<var>$verbose</var>ˤ<code>true</code>åȤ뤳Ȥˤʤ롣</p>
<h2><a name="label:5" id="label:5">ե饰 on/off</a></h2><!-- RDLabel: "ե饰 on/off" -->
<p>ե饰λä褦ˤ뤳ȤǤ롣</p>
<pre>require 'optparse'
$verbose = false
ARGV.options {|q|
  q.def_option('-v', '--[no-]verbose', 'run verbosely') {|$verbose|}
  q.parse!
} or exit(1)
puts "verbose=#$verbose"</pre>
<p>--verbose[no-]ȤΤդƤ뤬Ȥ뤳Ȥ̣Ƥ롣
<kbd>--no-verbose</kbd>ȻꤵС<var>$verbose</var>ˤ<code>false</code>åȤ롣</p>
<h2><a name="label:6" id="label:6">Υե饰</a></h2><!-- RDLabel: "Υե饰" -->
<pre>require 'optparse'
$execute = true
ARGV.options {|q|
  q.def_option('-v', '--[no-]verbose', 'run verbosely') {|$verbose|}
  q.def_option('-n', '--no-execute', 'not actually run') {|$execute|}
  q.parse!
} or exit(1)
puts "verbose=#$verbose"
puts "execute=#$execute"</pre>
<p><kbd>--no-execute</kbd>Ǥϡ[no-]ؤno-ȤʤäƤ롣
ΰ㤤ϡɤ餬ǥեȤˤʤäƤ뤫ĤޤûȤȤ
[]դξϹդƤʤǥեȤˤʤ롣
Ĥޤꡢñ<kbd>-v</kbd>Ȼꤵ줿Ȥ<var>$verbose</var><code>true</code>ˤʤ뤬
<kbd>-n</kbd>ʤ<var>$execute</var>ˤ<code>false</code>åȤ롣</p>
<hr />
<p>
<a name="foottext:1" id="foottext:1" href="footmark:1"><sup><small>*1</small></sup></a><small>ĹΥåФƤʸʸ϶̤ʤ</small><br />
<a name="foottext:2" id="foottext:2" href="footmark:2"><sup><small>*2</small></sup></a><small><code>def_option</code>ȤΤϸŤСǤϻȤʤ
ؤ<code>on</code>Ȥ</small><br />
<a name="foottext:3" id="foottext:3" href="footmark:3"><sup><small>*3</small></sup></a><small>ХѿȤ뤳Ȥ¿</small><br />
</p>
</body>
</html>