Be concise.
Be useful.
All contributions dictatorially edited by webmasters to match personal tastes.
Please do not paste any copyright violating material.
Please try to avoid dependencies to third-party libraries and frameworks.
(defn -main [arg & _]
(case arg
"b" (bat)
"f" (fox)
(nothing)))
void Main(string[] args)
{
if (args.Contains("b")) bat();
else if (args.Contains("f")) fox();
}
if (args.contains("b")) bat();
if (args.contains("f")) fox();
do i=1, command_argument_count ()
call get_command_argument (i, length=length)
if (length > len(opt)) then
deallocate (opt)
allocate (character(length) :: opt)
end if
call get_command_argument (i, opt)
if (opt(1:1) /= '-') exit
do j=2, length
select case (opt(j:j))
case ('b')
print *,"bat"
case ('f')
print *,"fox"
end select
end do
end do
const args = process.argv.slice(2)
if (args.includes('b')) bat()
else if (args.includes('f')) fox()
function HasOption(c: char): Boolean;
var
i: integer;
begin
Result := False;
for i := 1 to ParamCount do
if (ParamStr(i) = ('-' + c)) then Exit(True);
end;
begin
if HasOption('b') then Bat;
if HasOption('f') then Fox;
end.
for (@ARGV) {
use experimental 'switch';
bat when 'b';
fox when 'f';
}
options = {
'b': bat
'f': fox
}
for option, function in options:
if option in sys.argv[1:]:
function()
bat if ARGV.include?("b")
fox if ARGV.include?("f")
if let Some(arg) = ::std::env::args().nth(1) {
if &arg == "f" {
fox();
} else if &arg = "b" {
bat();
} else {
eprintln!("invalid argument: {}", arg),
}
} else {
eprintln!("missing argument");
}
if let Some(arg) = ::std::env::args().nth(1) {
match arg.as_str() {
"f" => fox(),
"b" => box(),
_ => eprintln!("invalid argument: {}", arg),
};
} else {
eprintln!("missing argument");
}