-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from rinogo/master
Add simple scripts
- Loading branch information
Showing
3 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" : ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" : ""); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" : ""); |