Skip to content

Commit 9ab99aa

Browse files
update
1 parent 8069d26 commit 9ab99aa

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

Capsule/CommandHelper.php

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,28 @@ protected function forceChecker(): void
7272
}
7373
}
7474
}
75+
76+
/**
77+
* Get force flag
78+
*/
79+
protected function force(): bool
80+
{
81+
// backtrace
82+
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4);
83+
84+
// get backtrace information about the caller's context
85+
$args = $this->debugTraceArgumentHandler($trace);
86+
87+
if(isset($args['force'])){
88+
return $args['force'];
89+
}
90+
91+
if(isset($args['f'])){
92+
return $args['f'];
93+
}
94+
95+
return false;
96+
}
7597

7698
/**
7799
* Extracts all arguments available from command
@@ -142,12 +164,28 @@ protected function hasFlag($key)
142164
return in_array($key, array_keys($args));
143165
}
144166

167+
/**
168+
* Extracts all options available from command
169+
*
170+
* @return array
171+
*/
172+
protected function options()
173+
{
174+
// backtrace
175+
$trace = debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 4);
176+
177+
// get backtrace information about the caller's context
178+
$args = $this->debugTraceArgumentHandler($trace);
179+
180+
return $args;
181+
}
182+
145183
/**
146184
* Get a specific option value from options array.
147185
* Example: option('force', false)
148186
*
149187
* @param string $key
150-
* @param string|array|bool|null $default
188+
* @param mixed $default
151189
*
152190
* @return mixed
153191
*/

Capsule/Logger.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ public static function success(string $message): void
259259
static::writeln("\n <success> SUCCESS </success> {$message}");
260260
}
261261

262+
public static function warning(string $message): void
263+
{
264+
static::writeln("\n <warning> WARNING </warning> {$message}");
265+
}
266+
262267
public static function error(string $message): void
263268
{
264269
static::writeln("\n <error> ERROR </error> {$message}");

0 commit comments

Comments
 (0)