public/tell.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
function tell {
    $clause = $args
    if ($args.Length) {
        $subject = $args[0]
        if ($args.Length -eq 1) {
            # E.g. tell me
            $phrase = '"what?"'
        }elseif ($args.Length -gt 1) {
            if ($args[1] -eq 'something') {
                # E.g. tell me something
                $phrase = '"what?"'
            }else {
                # E.g. tell me <something>...
                $phrase = $args[1..($args.Length - 1)]
            }
        }
    }
    invoke-expression "$( $phrase | % { $_ -join ',' } )"
}