Nuru icon indicating copy to clipboard operation
Nuru copied to clipboard

Allow % formating like in C like languages or fstring like python

Open gekkowrld opened this issue 1 year ago • 0 comments

Describe the feature

C like languages allow the user to "manipulate" strings using '%' e.g "%s" for strings, "%d" for decimals and so on. Python also has the same feature using .format() and f-strings.

Use Case

andika() currently only supports arbitrary number of arguments but no way of organizing them as per user needs.

Adding this will enable the user to do like:

fanya i = 0

fanya jina = jaza("Unaitwa nani rafiki? ")

wakati (i <= 5) {
		andika("Rafiki %s hii ni %d", jina, i)
		i++
}

(the same case with f-strings)

Proposed Solution

The golang and or python implementation details can be of use:

This are previous implementation details, not all the formatting will be copied over.

Other Information

No response

Acknowledgements

  • [X] This feature might incur a breaking change
  • [X] I may be able to implement this feature request

Version used

v0.5.1 (compiled from source with modifications from https://github.com/NuruProgramming/Nuru/pull/80)

Environment details (OS name and version, etc.)

GO VERSION: go version go1.22.1 linux/amd64 Kernel: 6.8.1-arch1-1 Shell: Bash OS: Arch Linux x86_64

gekkowrld avatar Mar 21 '24 19:03 gekkowrld