Comments (7)
I don't think there is an option type for that specific case. You can use the count option type multiple times, but it does not take a value.
You can use the map
or cast
option to achieve that though. Just pass in a function that will add the value to an array, and return the array of values.
from commando.
You can use the map or cast option to achieve that though. Just pass in a function that will add the value to an array, and return the array of values.
Could you please provide an example? Because I tried map
(not cast
though) and it was called only once...
from commando.
Wow. You are right. I totally missed that. I assumed it should work, but the tokens get deduped by array keys. Looks like it should be a fairly easy thing to fix though. I will look into putting up a PR soon.
from commando.
See PR #93 or my branch accumulator-for-multiple-options-of-same-name 47135e1489a0b765f8269f17599c9bed117dcd4a
from commando.
@NeoVance thanks man! I'll try it and write back
from commando.
Oh forgot to include the info.
reduce (Closure $reducer)
Aliases: list
, each
, every
Execute an accumulator/reducer function on every instance of the option in the command. Takes an accumulator function, and returns mixed (you can return any value). If you also supply a map for the option the map will execute on every value before it is passed to the accumulator function.
Signature: function(mixed $accumulated, mixed $value) : mixed
$accumulated
: null|Option::default|mixed (the last value returned from the function, the option default value, or null.)$value
: mixed (the value that comes after the option. if map is supplied, the value returned from the map function.)return
: mixed (anything you want. The last value returned becomes the value of the Option after parsing.)
from commando.
Merged 93
from commando.
Related Issues (20)
- Development appears abandoned. New fork created. HOT 1
- Feature request: Changelog HOT 1
- Command::printHelp() on Windows => file "nil" created with "tput command not found" HOT 1
- Setting an option value via array syntax is not permitted HOT 1
- PHP 8.1.1 - PHP Deprecated Warning ReturnTypeWillChange HOT 1
- Add option for a config file HOT 1
- Unable to parse option values that start with '-', e.g. negative numbers HOT 1
- Help doesn't short circuit HOT 1
- --help "Could not find the specified path" HOT 2
- How do I determine when a flag is actually passed into the cmd session? HOT 2
- Error when value is null
- Autoparsing on get option causes later option rules not to trip HOT 7
- Should be able to define more than one validation rule, and rules should allow for an error message HOT 1
- Feature request: create new `transform` method that both maps and validates values HOT 7
- Feture Request: conflictsWith (oppositive than needs)
- Impossible to read filename or '-' HOT 3
- Add an option to throw an exception or return instead of calling exit() HOT 1
- The main sample is not work
- Get all remaining items HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from commando.