Skip to content

Feature Suggestion: Fields  #197

Open
@rmasci

Description

@rmasci

I've added to my version of Script an option that I thought it might be useful to the rest of the Script users but I don't want to just issue a pull request that isn't wanted. I've documentation and tests as per the guidelines, let me know if this is wanted by the script team and I'll submit my pr.

Fields

We have the column option, and you can get one column IF its space separated. Fields takes three options. inDelimeter, outDelimeter, and the fields you want displayed. You could do something like this:

script.Echo("one;two;three;four").Fields(";","|",4,2,1,3).Stdout() and the the following output:

four|two|one|three

This has the input semicolon separated, the output is pipe separated, and the fields ordered. Fields would allow you to not only change the delimiter in and out, but specify the order of the output, or only the fields you want. If you had 10 columns you could specify only three of them, and put them in the desired order.

script.Echo("one;two;three;four;five;six;seven;eight;nine;ten").Fields(";","|",5,2,8).Stdout()

five|two|eight

I would have just rewrote Column, but that would break compatibility. So I created the Fields option. Maybe call it 'cut'?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions