Skip to content
This repository was archived by the owner on Oct 28, 2021. It is now read-only.

Better command line in rlp#4639

Merged
gumb0 merged 13 commits intoethereum:developfrom
demon1999:developrlp
Dec 7, 2017
Merged

Better command line in rlp#4639
gumb0 merged 13 commits intoethereum:developfrom
demon1999:developrlp

Conversation

@demon1999
Copy link
Contributor

No description provided.

Copy link
Member

@chfast chfast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for delays in reviews. Everyone is on devcon3.

rlp/main.cpp Outdated
otherInputs.push_back(arg);
}
if (vm.count("help")) {
cout << "Usage rlp <mode> [OPTIONS]" << endl << modesOptions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not expert here, but shouldn't the program_options be able to output that for us?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@codecov-io
Copy link

codecov-io commented Nov 3, 2017

Codecov Report

Merging #4639 into develop will increase coverage by 0.18%.
The diff coverage is 0%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #4639      +/-   ##
===========================================
+ Coverage     60.9%   61.09%   +0.18%     
===========================================
  Files          343      343              
  Lines        26999    27089      +90     
  Branches      2765     2779      +14     
===========================================
+ Hits         16444    16550     +106     
+ Misses        9603     9569      -34     
- Partials       952      970      +18
Impacted Files Coverage Δ
rlp/main.cpp 0% <0%> (ø) ⬆️
libethashseal/EthashProofOfWork.h 80% <0%> (-20%) ⬇️
libethereum/Transaction.h 53.84% <0%> (-18.38%) ⬇️
libethereum/Executive.h 52.17% <0%> (-14.5%) ⬇️
libethereum/Account.h 80% <0%> (-14.12%) ⬇️
libethcore/LogEntry.h 44% <0%> (-13.9%) ⬇️
libdevcrypto/Common.h 73.33% <0%> (-12.39%) ⬇️
libevm/VM.h 58.82% <0%> (-9.93%) ⬇️
libdevcore/CommonJS.h 90.32% <0%> (-9.68%) ⬇️
utils/json_spirit/json_spirit_value.h 57.52% <0%> (-9.15%) ⬇️
... and 40 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2cf4e7c...7072fd4. Read the comment docs.

@gumb0 gumb0 self-requested a review November 23, 2017 16:50
Copy link
Member

@gumb0 gumb0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, the help output looks a little weird now:

Usage rlp <mode> [OPTIONS]
Modes:
  -i [ --indent ] arg   <string>  Use string as the level indentation (default
                        '  ').
  --hex-ints            Render integers in hex.
  --string-ints         Render integers in the same way as strings.
  --ascii-strings       Render data as C-style strings or hex depending on
                        content being ASCII.
  --force-string        Force all data to be rendered as C-style strings.
  --force-escape        When rendering as C-style strings, force all characters
                        to be escaped.
  --force-hex           Force all data to be rendered as raw hex.
  -D [ --dapp ]         Dapp-building mode; equivalent to --encrypt --64.
    create <json>  Given a simplified JSON string, output the RLP.
    render [ <file> | -- ]  Render the given RLP. Options:
    list [ <file> | -- ]  List the items in the RLP list by hash and size.
    extract [ <file> | -- ]  Extract all items in the RLP list, named by hash.
    assemble [ <manifest> | <base path> ] <file> ...  Given a manifest & files, output the RLP.
General options:
  -e [ --encrypt ]      Encrypt the RLP data prior to output.
  -L [ --lenience ]     Try not to bomb out early if possible.
  -x [ --hex ]          Treat input RLP as hex encoded data.
  --base-16             Treat input RLP as hex encoded data.
  -k [ --keccak ]       Output Keccak-256 hash only.
  --base-64             Treat input RLP as base-64 encoded data.
  --64                  Treat input RLP as base-64 encoded data.
  -b [ --bin ]          Treat input RLP as raw binary data.
  --base-256            Treat input RLP as raw binary data.
  -q [ --quiet ]        Don't place additional information on stderr.
  -h [ --help ]         Print this help message and exit.
  -V [ --version ]      Show the version and exit.

We should figure out how to make it better, modes (create, render, list, extract, assemble) should be on the top, after Modes:
The options on top I think make sense for the render mostly, so maybe they should have title "Render Options"

Also please move -D into General options, because it's a combination of two other general options, I think it fits there better

rlp/main.cpp Outdated
prefs.escapeAll = true;
if (vm.count("nice"))
prefs.forceString = true, prefs.stringInts = false, prefs.forceHex = false, prefs.indent = " ";
if (vm.count("lenience"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's the duplicated piece of code from lenience till encrypt

@gumb0
Copy link
Member

gumb0 commented Nov 28, 2017

What if we change it to rlp --mode=<mode>, would it be easier to make help output look better and could we then get rid of handling unrecognized options?

The challenge might be in different modes having different number of arguments following them (like assemble has arbitrary number of files)

Check out also "positional options". maybe it helps somehow http://www.boost.org/doc/libs/1_58_0/doc/html/program_options/tutorial.html#idp337627504

@gumb0
Copy link
Member

gumb0 commented Nov 29, 2017

What happened to the indentation? Looks like it all changed to spaces

@demon1999
Copy link
Contributor Author

It's my fault. I'll fix it

Copy link
Member

@gumb0 gumb0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also further please use more descriptive commit messages than "Update main.cpp"

rlp/main.cpp Outdated
case Encoding::Keccak:
cout << sha3(_out).hex() << endl;
break;
case Encoding::Hex: case Encoding::Auto:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the indentation of casess inside switches, I just fixed it before in my commit here

@@ -1,16 +1,13 @@
/*
This file is part of cpp-ethereum.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove these empty lines in comments


hunter_add_package(Boost COMPONENTS filesystem system thread)
find_package(Boost CONFIG REQUIRED filesystem system thread)
hunter_add_package(Boost COMPONENTS program_options filesystem system thread)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hasn't this been merged to develop already?

<< renderOptions << generalOptions;
exit(0);
}
if (vm.count("lenience"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be a weird way of doing this. Can't we inform boost we would like to store this option in bool lenience variable and use the variable directly?

Copy link
Member

@gumb0 gumb0 Dec 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the way suggested by the official tutorials http://www.boost.org/doc/libs/1_65_1/doc/html/program_options/tutorial.html#idp437555840
But there's an option to store it in a local variable, too, I think.

This way is actually more compact (no need to define a local variable for each option), but duplicating the option name is a downside

@chfast
Copy link
Member

chfast commented Dec 6, 2017

Rebase and merge?

@gumb0
Copy link
Member

gumb0 commented Dec 6, 2017

I'll rebase it

@gumb0 gumb0 merged commit 40c7ceb into ethereum:develop Dec 7, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants