$ now :cmd \ 'set who "World"' \ 'print "Hello, $who!"' $ cat /etc/passwd | now :lp 'filter {:: to.lower | :: contains daemon}' ... _demod:*:275:275:Demo Daemon:/var/empty:/usr/bin/false _rmd:*:277:277:Remote Management Daemon:/var/db/rmd:/usr/bin/false ...
make test
LOG_LEVEL=DEBUG
GIT_SSH_COMMAND="ssh -i ~/.ssh/other-key"
ssh -i ~/.ssh/yet-another-key cleber@example.com
These things are ALWAYS present!
Subcommands and arg parsing:
Configuration:
Logging: logging
| name | limit |
| type | integer |
| default value | 100 |
| name | get_users |
| return type | list[User] |
| description | "Return a list of users" |
def download(bucket, key):def download(
bucket: str
key: str
) -> bytes:
def download(
bucket: str
key: str
) -> bytes:
"""Download an object from S3.
Parameters:
bucket (str) -- the bucket name to download from
key (str) -- the object key
Returns:
The downloaded object as bytes.
"""
[commands/hello]
description "Salute someone."
parameters {
who {
type string
default "World"
}
}
print "Hello, $who!"(The format is "key value")
[Hello Program]
This program implements the famous "hello, world!" while allowing the user to select who's being saluted.
[commands/hello]
description "Salute someone."
parameters {
who {
type string
default "World"
}
}
print "Hello, $who!"$ now Hello Program This program implements the famous "hello, world!" while allowing the user to select who's being saluted. hello ----------> Salute someone. who : string = World $ now hello Hello, World! $ now hello People Hello, People!
[Example Section]
is_example true
is_this_a_dict true
can_you_have_lists_here {
- of
- course
}
This is the body of the section, after the blank line.program: pipeline [{;|\n} pipeline [{;|\n} ...]]
pipeline: cmd_call [| command_call [| ...]]
cmd_call: name [arg1 [arg2 [...]]]A program is a list of pipelines
A pipeline is a list of command calls
All command calls follow the same format.
[tasks/connection_handler]
parameters {
connection {
type tcp_connection
}
}
o $connection | foreach data {
log "Data length: " ($data : length)
scope "SCGI" {
o $data | ... # SEE NEXT PAGE
set msg "Hello, world!"
| :: length
| as content_length
o $connection | :: send "Status: 200 OK
Content-Type: text/plain
Content-Length: $content_length
$msg"
break
}
}
o $connection | :: closeASGI connection handler example
o $data
| :: netstrings
| >> {
:: as headers_strings body
log "Headers strings: $headers_strings\nBody: $body"
return $headers_strings
}
| :: first | as headers_string
| :: c.strings | :: to.pairs | dict | as headers
| >> {:: get "REQUEST_URI" | as path | log "Path: "}
| >> {:: get "QUERY_STRING" | as query_params | log "Query parameters: "}
| >> {:: get "REQUEST_METHOD" | as request_method | log "Request method: "}Aproximate References:
:: - Namespaces
{} - Ruby blocks (and what |x| does)
>> - asides (some return, some not)
Shell:
Programs run in parallel
Write to pipe until full or closed
Next program read from pipe until closed
That is: the pipe is some sort of queue.
Now:
Program returns a range (think generators)
Next program walks through this range
That is: data is pulled, not pushed.
> range 1 5 | foreach number {print $number}
1
2
3
4
5
`range` returns a... range/iterator/generator
`foreach` walks through the range
Data is being pulled by `foreach`
Alternative syntax:
> range 1 5 | {print}
1
2
3
4
5
> set result [* [+ 1 2] 3] # Lisp-like, ugh!
> print $result
9
> set result (1 + 2 * 3) # Kinda Tcl-like -- much better!
> print $result
9
> o (1 + 2 * 3) # My ideas advance! My ideas RAGE!
| as result
| print
9