Skip to content

Commit

Permalink
Merge pull request #34 from rinogo/master
Browse files Browse the repository at this point in the history
Add simple scripts
  • Loading branch information
jbroadway committed Jul 29, 2015
2 parents bd33337 + 5218d12 commit 41b57e7
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
20 changes: 20 additions & 0 deletions scripts/downcode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//Downcode the provided argument or stdin if the argument was not present

require_once dirname (__DIR__) . '/URLify.php';

//Print usage and exit if arguments are invalid
if($argc < 1 || $argc > 2) {
die ("Usage (argument): php " . basename(__FILE__) . " \"<text to downcode>\"\nUsage (pipe): <Arbitrary command> | php " . basename(__FILE__) . "\n");
}

//Process the provided argument
if($argc === 2) {
$s = $argv[1];
//Or read from stdin if the argument wasn't present
} else {
$piped = true;
$s = file_get_contents("php://stdin");
}

echo URLify::downcode ($s) . ($piped ? "\n" : "");
20 changes: 20 additions & 0 deletions scripts/filter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//Filter the provided argument or stdin if the argument was not present

require_once dirname (__DIR__) . '/URLify.php';

//Print usage and exit if arguments are invalid
if($argc < 1 || $argc > 2) {
die ("Usage (argument): php " . basename(__FILE__) . " \"<text to filter>\"\nUsage (pipe): <Arbitrary command> | php " . basename(__FILE__) . "\n");
}

//Process the provided argument
if($argc === 2) {
$s = $argv[1];
//Or read from stdin if the argument wasn't present
} else {
$piped = true;
$s = file_get_contents("php://stdin");
}

echo URLify::filter ($s) . ($piped ? "\n" : "");
20 changes: 20 additions & 0 deletions scripts/transliterate.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
//Transliterate the provided argument or stdin if the argument was not present

require_once dirname (__DIR__) . '/URLify.php';

//Print usage and exit if arguments are invalid
if($argc < 1 || $argc > 2) {
die ("Usage (argument): php " . basename(__FILE__) . " \"<text to transliterate>\"\nUsage (pipe): <Arbitrary command> | php " . basename(__FILE__) . "\n");
}

//Process the provided argument
if($argc === 2) {
$s = $argv[1];
//Or read from stdin if the argument wasn't present
} else {
$piped = true;
$s = file_get_contents("php://stdin");
}

echo URLify::transliterate($s) . ($piped ? "\n" : "");

0 comments on commit 41b57e7

Please sign in to comment.