Closed destec closed 5 years ago
How is the output supposed to look?
I am writing V3 at the moment. This sounds like a breaking change. Therefore, it would be a good time to contribute thoughts about newline character support.
I was thinking more of this and I cannot see a valid use case for a newline character in the context of a tabular data. If you can provide an example, I will add this for future consideration.
Thanks for your concern @gajus . What I really need is to have multiple line in one cell for some reason. A bad code was like
var element1 = "a single line works perfect"
var element2 = "the first line \r\n the second line \r\n the third line"
var data = [[1, 2], [element1, element2]];
console.log(table(data));
As you can see, in the variable element2
I want to split the content into three lines and I used \r\n
as the symbol but it would have an error just I wrote before. And below is what I think it would look like:
1 | 2 |
---|---|
a single line works perfect | the first line the second line the third line |
There is no way to force a new line other than restricting the column width. As a simple workaround, I suggest to simply replace all instances of newline with a custom character that would visually indicate a line break, e.g. literal \n
.
Since @shellscape has brought this up again:
I don't remember the reason for not supporting a new line character. As far as I remember, my reasoning was that this is a fairly edge case requirement and it would introduce a considerable level of code complexity to support it without running into edge cases.
haha "hellscape" that sounds ominous. I don't think it's as edge-casey as it might seem. Aside from text-table, nearly every other table-printing module out there supports it. I was drawn in by the simple use and setup of table
. The alternative is to add rows with empty cells to fake a line break in a particular cell, and that's mighty hacky.
Sorry, copy-paste failure. :-)
I am certainly open to a PR.
Another use case would be pretty-printing json schema into one of the columns, eg:
type | schema |
---|---|
text | { prop: { \n prop2: 'value', \n prop3: 'value' \n } \n } |
In my case the schema is more complex with custom syntax highlighting. It does not make sense to transform it into another table.
I will second a feature request for this. Lack of this feature is a deal breaker for me.
I was thinking more of this and I cannot see a valid use case for a newline character in the context of a tabular data
Well it might turn out that your users have different use cases than you can imagine. In my case, I want to show structured complex data in each cell (lists of strings => newline separated strings, JSON => pretty-printed JSON).
You might want to put a disclaimer at the top of the description that is this library is explicitly not intended for use cases where you want to show something more than single scalar value in a cell.
I will second a feature request for this. Lack of this feature is a deal breaker for me.
Please contribute if this feature is important for you.
Fair enough request. I notice myself sounding like an entitled internet person, sorry for that.
In the mean time I've found a different library that does what I want, so I'm good :). Thanks for the response though.
Ha, turns out I settled on cli-table
, the thing you originally forked!
table
is not a fork of cli-table
.
Glad you found whats working for you though.
i get the following error while installing hyperledger caliper
cse@system:~$ sudo npx caliper benchmark run --caliper-workspace ./ --caliper-benchconfig ~/caliper/packages/caliper-samples/benchmark/drm/config.yaml --caliper-networkconfig ~/caliper/packages/caliper-samples/network/fabric-v1.4.1/2org1peergoleveldb/fabric-go.yaml [sudo] password for cse: Benchmark for target Blockchain type fabric about to start 2019.11.28-21:18:46.332 info [caliper] [caliper-flow] ####### Caliper Test ####### 2019.11.28-21:18:46.334 info [caliper] [local-observer] Observer interval set to 1 seconds 2019.11.28-21:18:46.335 info [caliper] [caliper-utils] Executing command: cd /home/cse;docker-compose -f caliper/packages/caliper-samples/network/fabriCreating orderer.example.com ... done Creating network "2org1peergoleveldb_default" with the default driver Creating peer0.org2.example.com ... done Creating ca.org1.example.com ... Creating orderer.example.com ... Creating peer0.org1.example.com ... Creating peer0.org2.example.com ... 2019.11.28-21:18:50.836 info [caliper] [adapters/fabric] Fabric SDK version: 1.4.0; TLS: none 2019.11.28-21:18:51.182 info [caliper] [adapters/fabric] Org1's registrar enrolled successfully 2019.11.28-21:18:51.322 info [caliper] [adapters/fabric] Org2's registrar enrolled successfully 2019.11.28-21:18:51.352 info [caliper] [adapters/fabric] Org1's admin's materials are successfully loaded 2019.11.28-21:18:51.361 info [caliper] [adapters/fabric] Org2's admin's materials are successfully loaded 2019.11.28-21:18:51.368 info [caliper] [adapters/fabric] client0.org1.example.com's materials are successfully loaded 2019.11.28-21:18:51.372 info [caliper] [adapters/fabric] client0.org2.example.com's materials are successfully loaded 2019.11.28-21:18:51.372 info [caliper] [adapters/fabric] Channel 'mychannel' definiton being retrieved from file 2019.11.28-21:18:51.404 info [caliper] [adapters/fabric] Channel 'mychannel' successfully created 2019.11.28-21:18:51.405 info [caliper] [adapters/fabric] Sleeping 5s... 2019.11.28-21:18:56.509 info [caliper] [adapters/fabric] Org1's peers successfully joined mychannel: peer0.org1.example.com 2019.11.28-21:18:56.664 info [caliper] [adapters/fabric] Org2's peers successfully joined mychannel: peer0.org2.example.com 2019.11.28-21:18:56.664 info [caliper] [adapters/fabric] Sleeping 5s... 2019.11.28-21:19:01.668 info [caliper] [adapters/fabric] Installing chaincodes for mychannel... 2019.11.28-21:19:01.749 info [caliper] [adapters/fabric] marbles@v0 successfully installed on Org1's peers: peer0.org1.example.com 2019.11.28-21:19:01.758 info [caliper] [adapters/fabric] marbles@v0 successfully installed on Org2's peers: peer0.org2.example.com 2019.11.28-21:19:01.771 info [caliper] [adapters/fabric] drm@v0 successfully installed on Org1's peers: peer0.org1.example.com 2019.11.28-21:19:01.778 info [caliper] [adapters/fabric] drm@v0 successfully installed on Org2's peers: peer0.org2.example.com 2019.11.28-21:19:01.793 info [caliper] [adapters/fabric] simple@v0 successfully installed on Org1's peers: peer0.org1.example.com 2019.11.28-21:19:01.798 info [caliper] [adapters/fabric] simple@v0 successfully installed on Org2's peers: peer0.org2.example.com 2019.11.28-21:19:01.811 info [caliper] [adapters/fabric] smallbank@v0 successfully installed on Org1's peers: peer0.org1.example.com 2019.11.28-21:19:01.816 info [caliper] [adapters/fabric] smallbank@v0 successfully installed on Org2's peers: peer0.org2.example.com 2019.11.28-21:19:01.816 info [caliper] [adapters/fabric] Instantiating marbles@v0 in mychannel. This might take some time... 2019.11.28-21:19:02.768 info [caliper] [adapters/fabric] Successfully instantiated marbles@v0 in mychannel 2019.11.28-21:19:02.771 info [caliper] [adapters/fabric] Instantiating drm@v0 in mychannel. This might take some time... 2019.11.28-21:19:03.582 info [caliper] [adapters/fabric] Successfully instantiated drm@v0 in mychannel 2019.11.28-21:19:03.583 info [caliper] [adapters/fabric] Instantiating simple@v0 in mychannel. This might take some time... 2019.11.28-21:19:05.382 info [caliper] [adapters/fabric] Successfully instantiated simple@v0 in mychannel 2019.11.28-21:19:05.384 info [caliper] [adapters/fabric] Instantiating smallbank@v0 in mychannel. This might take some time... 2019.11.28-21:19:06.711 info [caliper] [adapters/fabric] Successfully instantiated smallbank@v0 in mychannel 2019.11.28-21:19:06.713 info [caliper] [adapters/fabric] Sleeping 5s... 2019.11.28-21:19:12.943 info [caliper] [caliper-flow] Started monitors successfully 2019.11.28-21:19:12.945 info [caliper] [defaultTest] ####### Testing 'publish' ####### 2019.11.28-21:19:12.946 info [caliper] [defaultTest] ####### Testing 'query' ####### 2019.11.28-21:19:12.946 info [caliper] [caliper-flow] ---------- Finished Test ----------
2019.11.28-21:19:12.947 info [caliper] [report-builder] ### All test results ###
2019.11.28-21:19:12.947 error [caliper] [caliper-flow] Error: Error: Table must define at least one row.
at exports.default.rows (/home/cse/node_modules/table/dist/validateTableData.js:26:11)
at Object.exports.default [as table] (/home/cse/node_modules/table/dist/table.js:115:35)
at Report.printTable (/home/cse/node_modules/@hyperledger/caliper-core/lib/report/report.js:133:23)
at Report.printResultsByRound (/home/cse/node_modules/@hyperledger/caliper-core/lib/report/report.js:255:14)
at Object.module.exports.run (/home/cse/node_modules/@hyperledger/caliper-core/lib/caliper-flow.js:119:20)
at
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images docker: "images" requires a maximum of 1 argument. See 'docker images --help'.
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images docker: "rmi" requires a minimum of 1 argument. See 'docker rmi --help'.
Usage: docker rmi [OPTIONS] IMAGE [IMAGE...]
Remove one or more images
Benchmark failure
Error: Benchmark failure
at Function.handler (/home/cse/node_modules/@hyperledger/caliper-cli/lib/benchmark/lib/runBenchmark.js:70:23)
at
I want to start a new line in a single cell, so I tried to add '\r\n' or '\n' at the end of the line. But it seems like it will be forbidden because of the regex test in validateData.js line 58:
/[\x01-\x1A]/.test(cell)
. So is there any way to have a new line?