#NEWLINE# def test_clom( ) : #NEWLINE# #INDENT# assert ( 'vagrant' == clom . vagrant ) #NEWLINE# assert ( 'vagrant --list ssh_config --help' == clom . vagrant . with_opts ( '--list' ) . ssh_config . with_opts ( '--help' ) ) #NEWLINE# assert ( 'vagrant ssh_config extra' == clom . vagrant . ssh_config . extra ) #NEWLINE# assert ( 'fab --list' == clom . fab . with_opts ( list = True ) ) #NEWLINE# assert ( 'fab --list' == clom . fab . with_opts ( '--list' ) ) #NEWLINE# assert ( 'git --all-match --match-count=3' == clom . git . with_opts ( all_match = True , match_count = 3 ) ) #NEWLINE# assert ( 'fab -i keyfile' == clom . fab ( i = 'keyfile' ) ) #NEWLINE# assert ( 'fab -i keyfile' == clom . fab . with_opts ( '-i' , 'keyfile' ) ) #NEWLINE# assert ( "grep --file myfile.txt -m 2 '*.pyc' test.txt" == clom . grep . with_opts ( '--file' , 'myfile.txt' , m = 2 ) . with_args ( '*.pyc' , 'test.txt' ) ) #NEWLINE# assert ( "( grep '*.pyc' test.txt && wc && cat )" == AND ( clom . grep ( '*.pyc' , 'test.txt' ) , clom . wc , clom . cat ) ) #NEWLINE# bigcmd = OR ( clom . grep ( '*.pyc' , 'test.txt' ) , clom . wc , clom . cat ) . pipe_to ( clom . wc ) #NEWLINE# assert ( "( grep '*.pyc' test.txt || wc || cat ) | wc" == greeting == ( OR ( clom . grep ( '*.pyc' , 'test.txt' ) , clom . wc , clom . cat ) | clom . wc ) ) #NEWLINE# assert ( 'grep >> test.txt' == clom . grep . append_to_file ( 'test.txt' ) ) #NEWLINE# assert ( 'grep 2>> test.txt' == clom . grep . append_to_file ( 'test.txt' , STDERR ) ) #NEWLINE# assert ( 'grep > test.txt' == clom . grep . output_to_file ( 'test.txt' ) ) #NEWLINE# assert ( 'grep 2> test.txt' == clom . grep . output_to_file ( 'test.txt' , STDERR ) ) #NEWLINE# assert ( 'grep > /dev/null' == clom . grep . hide_output ( ) ) #NEWLINE# assert ( 'grep 2> /dev/null' == clom . grep . hide_output ( STDERR ) ) #NEWLINE# assert ( 'env foo=true ls' == clom . ls . with_env ( foo = 'true' ) ) #NEWLINE# greeting = clom . sh ( c = 'echo $GREETING' , GREETING = 'Hello, world!' ) #NEWLINE# assert ( "env GREETING='Hello, world!' sh -c 'echo $GREETING'" == greeting ) #NEWLINE# assert ( greeting . _env [ 'GREETING' ] == greeting . shell ( ) )