WSH で Usage を表示する
拡張子 .wsf のファイルでは、XMLをちょろっと書くだけで Usage (使用方法) が生成できます。
<?xml version="1.0" encoding="utf-8"?>
<package>
<job>
<runtime>
<description>サンプルスクリプトです。</description>
<named
name="A"
helpstring="名前つき引数Aです"
type="string"
required="true"/>
<named
name="B"
helpstring="名前つき引数Bです"
type="boolean"
required="false"/>
<named
name="C"
helpstring="名前つき引数Cです"
type="simple"
required="false"/>
<unnamed
name="arga"
helpstring="名前なし引数Aです"
many="false"
required="true"/>
<unnamed
name="argb"
helpstring="名前なし引数Bです"
many="true"
required="false"/>
<example></example>
</runtime>
<script language="JScript"><![CDATA[
WScript.Arguments.ShowUsage ();
]]></script>
</job>
</package>
>cscript test.wsf /? Microsoft (R) Windows Script Host Version 5.6 Copyright (C) Microsoft Corporation 1996-2001. All rights reserved. サンプルスクリプトです。 使い方 : test.wsf /A:値 [/B[+|-]] [/C] arga [argb1 argb2...] オプション : A : 名前つき引数Aです B : 名前つき引数Bです C : 名前つき引数Cです arga : 名前なし引数Aです argb : 名前なし引数Bです
サンプルの script 要素内にもありますが WScript.Arguments.ShowUsage (); でプログラム内から表示させることもできるので、引数が不正な時などにも使えそうです。
トラックバック
- このエントリーにトラックバック:
- http://frog.raindrop.jp/cgi-bin/mt/mt-tb.cgi/1970
コメント