Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'string.*' command group #59

Closed
pyroscope opened this issue Mar 17, 2017 · 5 comments
Closed

Add 'string.*' command group #59

pyroscope opened this issue Mar 17, 2017 · 5 comments

Comments

@pyroscope
Copy link
Owner

pyroscope commented Mar 17, 2017

https://rtorrent-docs.readthedocs.io/en/latest/cmd-ref.html#string-functions

  • ✔️ Update / finish documentation
  • ✔️ UTF8 support for all this!
  • ✔️ string.len → value
  • ✔️ string.substr → string
  • ✔️ string.strip → string (optional char sequence to strip, lstrip / rstrip?)
  • ✔️ string.replace → string
  • ✔️ string.map → string
  • ✔️ string.split → list
  • ✔️ string.join → string – like cat, but with a delimiter
  • ✔️ string.contains[_i] → value
  • ✔️ string.equals → value
  • ✔️ string.endswith → value
  • ✔️ string.startswith → value
  • string.chop – see string.substr
  • ✔️ string.[lr]pad → string
@pyroscope
Copy link
Owner Author

See also 3b9b5e7

@pyroscope pyroscope self-assigned this Oct 1, 2017
@chros73
Copy link
Contributor

chros73 commented Apr 23, 2018

I create 2 new methods that should work like math.* commands (accepting both string and number but not list), what shall I call the group?
data.* or chars.* or ... ?

  • exposing u8_chop : chars.chop (accepts max 3 params)
    • print=(chars.chop, "1234567", 3, 1) -> 12…
  • chars.pad (accepts max 4 param)
    • print=(chars.pad, "123", 5, "0", 1) -> 00123

These can be chained together as well:

  • print=(chars.pad, (chars.chop, "1234567", 3), 5, "x") -> 123xx

This group suppose to deal with "strings" and do some manipulation on them, but it behaves differently than the string.* group.
They can be used to display something on the UI or during logging (log.execute).

Thanks

Edit: I picked chars.*

@chros73
Copy link
Contributor

chros73 commented May 30, 2018

Here's the usage examples for the chars.* group, I extended your idea of logging.
Thanks for this as well!

@pyroscope pyroscope added this to the PS-1.1 milestone May 30, 2018
@pyroscope
Copy link
Owner Author

A string is a list of chars, I don't see the need for a new group name. That they implicitly convert values is not enough ‘different’ for me. Things are complicated enough, and adding a stink of PHP doesn't help. ;)

@chros73
Copy link
Contributor

chros73 commented May 30, 2018

:D :D :D You can rename them in ps, and I will rename it in ch if the setup project will reach 1.0 (I want to do couple of nontrivial things until then). That's why I asked for your opinion back then. It matters for me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants