Implementation
Ruby

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
import std.getopt;
void main(string[] args)
{
    void bat(){} void fox(){}
    getopt(args, "b", &bat, "f", &fox);
}
import "flag"
var b = flag.Bool("b", false, "Do bat")
var f = flag.Bool("f", false, "Do fox")

func main() {
	flag.Parse()
	if *b {
		bar()
	}
	if *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.
import sys
if 'b' in sys.argv[1:]: bat()
if 'f' in sys.argv[1:]: fox()
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");
}
#include <unistd.h>
int main(int argc, char * argv[])
{
        int optch;
        while ((optch = getopt(argc, argv, "bf")) != -1) {
                switch (optch) {
                        case 'b': bat(); break;
                        case 'f': fox(); break;
                }
        }
        return 0;
}
for (@ARGV) {
    use experimental 'switch';
    bat when 'b';
    fox when 'f';
}
  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
void Main(string[] args)
{
  if (args.Contains("b")) bat();
  else if (args.Contains("f")) fox();
}
options = {
	'b': bat
	'f': fox
}

for option, function in options:
	if option in sys.argv[1:]:
		function()