Sha256: 0d8b74258663a52bd2c2f5d9526432ca88d42337eeb0cf5e38f8a6c49eb3af34
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
ARGV documentation: """ ARGV is a singleton instance of @Array@ and holds all (command-line) arguments passed to a Fancy programm before it starts executing. """ def ARGV for_option: op_name do: block { "Runs a given block if an option is in ARGV." ARGV index: op_name . if_true: |idx| { if: (block arity > 0) then: { ARGV[idx + 1] if_true: |arg| { block call: [arg] ARGV remove_at: idx ARGV remove_at: idx } } else: { block call ARGV remove_at: idx } } } def ARGV for_options: op_names do: block { "Runs a given block if any of the given options is in ARGV." op_names size times: |i| { if: (ARGV index: (op_names[i])) then: |idx| { if: (block arity > 0) then: { if: (ARGV[idx + 1]) then: |arg| { block call: [arg] ARGV remove_at: idx ARGV remove_at: idx } } else: { block call ARGV remove_at: idx } return true } } } def ARGV main?: filename { if: (ARGV[0]) then: { File expand_path: (ARGV[0]) . == filename } }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fancy-0.7.0 | lib/argv.fy |
fancy-0.6.0 | lib/argv.fy |