-
Notifications
You must be signed in to change notification settings - Fork 16
File operations
Pake includes various utilities for common operations. Here they are:
Checks if $path directory exists, and if it doesn’t, creates $path directory recursively. You don’t need to do additional file_exists() or is_dir() calls. Just call pake_mkdirs(“foo/bar/baz”) and everything will be done automatically
Again, Pake will do all required checks and will even create target directory for you, if it doesn’t exist. By default, pake will only copy file if $origin_file is newer than $target_file. You can override it by giving array(‘override’ => true) as the last parameter.
Renames file specified as the first parameter to the name specified by the second parameter.
Copies all files and directories which correspond to the $arg rule from $origin_dir to $target_dir. Options parameter is forwarded to pake_copy(), which is used internally.
Deletes all files and directories which correspond to the $arg rule from $target_dir
Updates “modified time” of files, which correspond to the $arg rule in $target_dir
TODO
TODO
Creates symlink from $origin_dir to $target_dir. if $copy_on_windows is set to TRUE, then pake_mirror() will be used, in case when symlink functionality is not supported by OS.
Applies new POSIX mode to files found by $arg rule in $target_dir. Notice: it is not safe to rely on umask in multithreaded environment.
Parse all files found by $arg rule in $target_dir and, if those are php-files, removes comments from them.
Executes shell-command. If $interactive flag is not set STDOUT is not shown, but is returned instead. STDERR still goes straight to the screen, which allows to show password-request dialogs, for example.
On the other hand, if $interactive flag is set, then command is attached to standard stdin/stdout streams and user can interact with process. This is useful for running editors, for example.
Command if similar to pake_sh() but it tries to run command as superuser. If current user is “root”, already, then it just forwards call to pake_sh(). Otherwise, it will try to run command with sudo or su, depending on their availability.
This function shows the question and then waits for input from the user. As soon as user presses Enter-key input is returned from this function. It works like this:
<?php
$age = pake_input("How old are you?");
pake_echo_comment('Your age is: '.$age);
?>
How old are you? [>] 18 # Your age is: 18
This function shows the question and provides several options, waiting for input from the user. As soon as user presses Enter-key input is returned from this function. $default, if specified, has to be numeric index of default option. It works like this:
<?php
$options = array(
'< 18',
'18–25',
'25–45',
'> 45'
);
$result = pake_select_input('How old are you?', $options, 1);
pake_echo('Your age is: '.$result);
?>
How old are you? (1) < 18 (2) 18–25 (3) 25–45 (4) > 45 [> default="2"] 2 Your age is: 18–25
This is a standard mean for outputting progress information to the user. Resulting string is divided in 2 columns (each of those is left-aligned). It looks like this:
>> section action text goes here
Deliever commenting-message to the user (it will be yellow, if user’s terminal supports colors)
Deliever error-message to the user (it will be red and alarming, if user’s terminal supports colors)
This one just prints free-form message to the user (that is, if she want to see messages). No need to add “\n”
<?php
pake_echo("Hello!");
pake_echo("World!");
?>