Giter VIP home page Giter VIP logo

cork's People

Contributors

homoelectromagneticus avatar jcallicoat avatar mgaggero avatar reddocmd avatar zenithsiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cork's Issues

Allow disabling the welcome message

The welcome message is cute:

$ cork
Welcome to cork - a calculator for hex-lovers!
Press Ctrl + D to exit.
cork> 

but is far from being crucial: there should be a way to disable it, if desired.

A good way would be through an option in a config file (see #2).

Implement easy-to-use temporary `of` modifier

It's nice to be able to set of to another base but is still a bit verbose, in particular when done for a single operation.

Could cork be extended to support an operator that temporarily switches of to what makes sense in a "do what I mean" manner?

For example, the ? operator could result in hex values being printed as decimal and decimal as hex, irrespective of of. Consider

cork> set of dec
cork> 1 + 1
2
cork> 42?
0x2a
cork> set of hex
cork> 0x10 + 0x10
0x20
cork> 0x100?
256

instead of having to manually manage of:

cork> set of hex
cork> 42
0x2a
cork> set of dec
cork> set of dec
cork> 0x100
256
cork> set of hex

I can't decide whether ?'s behavior should be dependent on of, though ...

If support for more niche bases is desired (or to disambiguate complex expressions), ? could also take an optional right operand that represents the requested base:

cork> set of hex
cork> 0x20 + 3
0x23
cork> 0x20 + 3?
Failed to parse "0x20 + 3?":  --> 1:9
  |
1 | 0x20 + 3?
  |         ^---
  |
  = ambiguous expression, expected right operand for base
cork> 0x20 + 3?b
0b100011
cork> 0x20 + 3?d
35

Another approach could also be to overload the case of receiving a single literal of the current of by reflecting it in the alternative base:

cork> set of hex
cork> 0x100
256
cork> set of dec
cork> 256
0x100

which is definitely more informative than the current behavior:

cork> set of hex
cork> 0x100
0x100
cork> set of dec
cork> 256
256

If worth the added complexity, support for other alternative bases than the respective "default ones" (i.e. hex for decimal and decimal for hex), could be implemented through a new set property. For example:

cork> set of hex
cork> set alter_of bin
cork> 0x100
0b100000000

warning: field `0` is never read

Hi, here in Windows I'm building the v0.2.6 and shows:

warning: field `0` is never read
  --> src\expression.rs:46:25
   |
46 | pub struct ParseOpError(String);
   |            ------------ ^^^^^^
   |            |
   |            field in this struct
   |
   = note: `ParseOpError` has a derived impl for the trait `Debug`, but this is intentionally ignore
d during dead code analysis
   = note: `#[warn(dead_code)]` on by default
help: consider changing the field to be of unit type to suppress this warning while preserving the f
ield numbering, or remove the field
   |
46 | pub struct ParseOpError(());
   |                         ~~

warning: `cork` (bin "cork") generated 1 warning
    Finished release [optimized] target(s) in 0.44s

Cheers.

Feature request: multiple output formats

I'd like to be able to specify multiple output formats, e.g.

set of hex bin dec

so that each answer is displayed in these radixes:

    cork> 10+2
0xb       0b1011    12

Ideally with a nice tabulated/table output, e.g.

----------------------------
| 0xb      | 0b1011   | 12    |
-----------------------------

Support separators in long numbers

For readability of the numbers, it is sometimes desired to add separators to long numbers (for example, writing 0x3000_0000 to avoid confusion with 0x3000000 or 0x300000000); could this be supported by cork? As long as those separators aren't valid operators, it should simply mean stripping arguments from expected separators before converting them to integers.

As an illustration, consider the following:

cork> 0x3000_0000 + 0x200_0000
Failed to parse "0x3000_0000 + 0x200_0000":  --> 1:7
  |
1 | 0x3000_0000 + 0x200_0000
  |       ^---
  |
  = expected EOI, add, subtract, multiply, divide, rem, lshift, or rshift

Although this is requested for hex numbers, I guess it would also be valid for other bases and characters other than _: for example 10'000'000, 10,000,000? The hex case being the most interesting, of course.

Accept file to run as script

Lines are interpreted the same way if they had been typed in.
Evaluated in order, expressions give outputs. Set directives
are evaluated, but emit no output.

  • Short arg: "-f"
  • Long arg: "--file"

Direct operations with batch file

Hi, it would awesome if were possible to make direct operations on a single line, so it can be used with a batch file, something like:
cork 0x4DEE72 + 0x18CF5 >filename.txt
Actually it outputs :

error: Found argument '0x4DEE72' which wasn't expected, or isn't valid in this context

USAGE:
    cork [OPTIONS]

For more information try --help

Cheers

Add support for one-off operations through `argv`

Cork currently ignores command-line arguments; instead, it could be extended to accept an expression, compute and print it, and exit.

For example:

$ cork 0x10 + 0x10
0x20
$ cork
Welcome to cork - a calculator for hex-lovers!
Press Ctrl + D to exit.
cork> 0x10 + 0x10
0x20
cork>

(note that, in the first case, cork returns immediately)

"Convert to a different radix" command.

Hi,
it would be really useful to have a "to radix" command to quickly and temporary convert a number or the result of an expression to a different radix (for example when working with memory address and segments sizes):

cork> 0xCAFE to dec
51966
cork> 0xCAFE + 2 * 8 * 0x20 to dec
52478
cork> 0xCAFE + 2 * 8 * 0x20
0xccfe
cork> ans to bin
0b1100110011111110
cork> 1234 to hex
0x4d2
cork> (0xCAFE + 2 * 8 * 0x20) to oct
0o146376

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.