nushell: Shouldn't `split column` and `split chars` be `str` subcommands?

Question

I was thinking that str subcommands are exclusively commands which take and return strings. However, I’ve noticed str index-of is there, which returns a number. So, shouldn’t split column and split chars, which return structures of strings, be str subcommands too? I just want to understand how these commands are batched together.

Additional context and details

No response

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Comments: 18 (11 by maintainers)

Most upvoted comments

This is how I would parse the /etc/passwd on my Mac, not sure it’s the same on Linux.

 open /etc/passwd | lines | skip 10 | parse "{user}:{pass}:{userid}:{groupid}:{fullname}:{path}:{other}"

or alternately

open /etc/passwd | lines | skip 10 | to text | from csv --separator ':'

detect columns and from ssv are really for parsing space delimited files.

I’m not sure exactly how to use split columns myself, other than what the examples show.

As an addendum to the original post: I think split rows, which is the “fundamental” split analogous to JS and Python .split(), is too difficult to discover and should not require the word rows at all. I think the columns version is also pretty bizarre, insofar as one can simply add | rotate --ccw to rows’s output to get the same result.

I think we need to have a balance between having a bunch of commands that do similar things and having one command that has dozens of command line parameters. In general we want to have easy to use intuitive composable commands.

My problem with putting detect columns functionality into from ssv is really about the name. from ssv just doesn’t say to me that we want to take some human readable columnar output and transform it to nushell tables. On the other hand, if I have a csv that is delimited by spaces instead of commas, I think of from ssv.

Having said that, I could see taking the detect columns “guts” and putting it in as from ssv --detect. I still have the same problem with the naming but I’m not really sure what to do about it.

Linux has columns -t and tabulate but I’m not really sure those names are better. I’m open to other suggestions. Anyone have any good ones?

You’re right @dandavison, parse should be in the same conversation. Maybe we should have parse columns that does the detect columns/from ssv work?