gavinhoward / bc

An implementation of the POSIX bc calculator with GNU extensions and dc, moved away from GitHub. Finished, but well-maintained.
https://git.gavinhoward.com/gavin/bc
Other
162 stars 32 forks source link

Additional arguments #43

Closed depler closed 3 years ago

depler commented 3 years ago

Can you please implement some new command line arguments?

  1. Ability to print equation result without line breaks, i.e. just a solid text.
  2. Ability to force prepending zero in equation result, i.e. 0.123 instead of current .123
gavinhoward commented 3 years ago

Those are good ideas.

For the first, there is already an environment variable, BC_LINE_LENGTH, that can be used to do that. You just set it to a large number. Would that work, or would that still not be convenient (and I use that word for a reason; I do want it to be easy for you) on Windows? Also, if you want a separate option to remove line limits entirely, why?

For the second, I think that one might be a really good idea. EDIT: However, could this be implemented by something like a function in the math library such that it's not a global option affecting all numbers? Would that be better? Should we have both?

In both of these cases, I don't want to just willy-nilly implement something; I want them to be designed correctly. So I'll get started on that, but please feel free to give me your opinions about the design of them.

depler commented 3 years ago

Also, if you want a separate option to remove line limits entirely, why?

This is exactly what I want - remove line limits entirely. Environment variables are not really useful on Windows unless you heavily use scripts. Usually you just run executable with desired variables to archive functionality (or using some config file as alternative).

However, could this be implemented by something like a function in the math library such that it's not a global option affecting all numbers? Would that be better? Should we have both?

For exactly my needs global option is preferable - I just want to see all numbers in range -1 < 0 < 1 with zero.

So if you you think that environment variables are needed - feel free to implement both. Personally I don't like to use environment switches, command arguments are more convenient for me.

gavinhoward commented 3 years ago

Good to know. Let me get on that and see if I can come up with something that works for you.

gavinhoward commented 3 years ago

I have added the two command line arguments (z and C). Could you please pull and test that they do what you want?

I'm not done yet, but the rest of the work is not really going to impact what you want. It's a way to query the status of those things so that I can write library functions to print them in different ways.

gavinhoward commented 3 years ago

I've changed the options to -z/--leading-zeroes and -L/--no-line-length.

depler commented 3 years ago

Working fine, thanks! Can you please add new tests to windows scripts? It is just a new lines with filename of appropriate test in tests_bc.bat and tests_dc.bat.

gavinhoward commented 3 years ago

I'm sorry, I feel stupid, but I'm not sure what tests you want me to add. For these features? Or more tests in general?

depler commented 3 years ago

You've added this one (and may be something else): https://github.com/gavinhoward/bc/blob/master/tests/bc/leadingzero.txt Windows script doesn't know about it yet.

gavinhoward commented 3 years ago

I see. I've added that test to the Windows bat file, but once again, can you pull and test for me? The reason is that it needs to run the test twice, and I want to be sure that works for you.

depler commented 3 years ago

A few changes are needed to differ leadingzero test from leadingzero_z : https://github.com/gavinhoward/bc/pull/44 Otherwise it works fine.

gavinhoward commented 3 years ago

44 is merged. Is there anything else that needs to change for you?

depler commented 3 years ago

Nope. Thanks 👍