Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Display CLI usage on user error #819

Merged
merged 4 commits into from
Sep 20, 2022

Conversation

orpheuslummis
Copy link
Contributor

@orpheuslummis orpheuslummis commented Sep 19, 2022

Relevant issue(s)

Resolves #669

Description

Displays usage text on 'user error' (failure to summon a valid command).

Given current release timeline, I suggest tests for this are to be included in next release.

Limitations:

  • Displaying DefraDB error in addition of the error itself because internal logger interface doesn't allow to display directly an error and its stacktrace (when we configured to display stacktrace).
  • Risk of false positive, of displaying usage when an internal error bubbles up that starts with one of these given 'cobra errors' strings.
  • Risk of cobra error strings changing and therefore the usage help not being displayed, ie. regressing to behavior before this PR. It seems unlikely the list of cobra errors will change much, as they cover basic functionality, and the messages are covered by tests in the cobra codebase.

I thought that was the least worse way to achieve this UX feature given the options I considered (listed in the issue).

Tasks

  • I made sure the code is well commented, particularly hard-to-understand areas.
  • I made sure the repository-held documentation is changed accordingly.
  • I made sure the pull request title adheres to the conventional commit style (the subset used in the project can be found in tools/configs/chglog/config.yml).
  • I made sure to discuss its limitations such as threats to validity, vulnerability to mistake and misuse, robustness to invalidation of assumptions, resource requirements, ...

How has this been tested?

Manual

Specify the platform(s) on which this was tested:

  • MacOS

@orpheuslummis orpheuslummis added the area/cli Related to the CLI binary label Sep 19, 2022
@orpheuslummis orpheuslummis added this to the DefraDB v0.3.1 milestone Sep 19, 2022
@orpheuslummis orpheuslummis self-assigned this Sep 19, 2022
@orpheuslummis orpheuslummis added the action/no-benchmark Skips the action that runs the benchmark. label Sep 19, 2022
@codecov
Copy link

codecov bot commented Sep 19, 2022

Codecov Report

Merging #819 (3c7e4e2) into develop (1363cce) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop     #819      +/-   ##
===========================================
- Coverage    59.57%   59.56%   -0.02%     
===========================================
  Files          155      155              
  Lines        17271    17275       +4     
===========================================
  Hits         10290    10290              
- Misses        6051     6055       +4     
  Partials       930      930              
Impacted Files Coverage Δ
cli/blocks_get.go 4.44% <0.00%> (+0.18%) ⬆️
cli/cli.go 20.00% <0.00%> (-0.94%) ⬇️

@orpheuslummis orpheuslummis changed the title feat: Display usage on user errors using the CLI feat: Display CLI usage on user error Sep 19, 2022
@source-devs
Copy link

Benchmark Results

Summary

  • 113 Benchmarks successfully compared.
  • 104 Benchmarks were ✅ Better.
  • 9 Benchmarks were ❌ Worse .
  • 0 Benchmarks were ✨ Unchanged.
✅ See Better Results...
time/opdelta
_Collection_UserSimple_Create_Sync_0_10-49.72ms ± 0%9.61ms ± 0%−1.08%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-498.4ms ± 0%97.3ms ± 0%−1.09%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-4981ms ± 0%972ms ± 0%−0.91%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-444.1ms ± 0%43.1ms ± 0%−2.38%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4442ms ± 0%421ms ± 0%−4.83%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-44.49s ± 0%4.35s ± 0%−3.25%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4321µs ± 0%321µs ± 0%−0.11%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-43.50ms ± 0%3.36ms ± 0%−4.17%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-438.6ms ± 0%36.2ms ± 0%−6.05%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4358µs ± 0%344µs ± 0%−3.71%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-43.69ms ± 0%3.62ms ± 0%−1.93%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-41.81ms ± 0%1.72ms ± 0%−4.86%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-423.4ms ± 0%21.8ms ± 0%−6.57%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4259µs ± 0%250µs ± 0%−3.81%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-41.84ms ± 0%1.72ms ± 0%−6.32%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-41.14ms ± 0%1.10ms ± 0%−3.69%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-49.02ms ± 0%8.45ms ± 0%−6.41%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4448µs ± 0%418µs ± 0%−6.74%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-41.22ms ± 0%1.18ms ± 0%−2.70%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-49.41ms ± 0%8.79ms ± 0%−6.59%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4407µs ± 0%386µs ± 0%−5.24%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4501µs ± 0%430µs ± 0%−14.22%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4457µs ± 0%432µs ± 0%−5.49%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-4646µs ± 0%643µs ± 0%−0.51%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-4682µs ± 0%608µs ± 0%−10.78%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-4676µs ± 0%630µs ± 0%−6.73%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4441µs ± 0%402µs ± 0%−9.01%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-41.25ms ± 0%1.19ms ± 0%−5.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-49.64ms ± 0%9.06ms ± 0%−6.04%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4333µs ± 0%288µs ± 0%−13.61%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4314µs ± 0%291µs ± 0%−7.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4299µs ± 0%289µs ± 0%−3.07%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-413.3µs ± 0%12.4µs ± 0%−6.86%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-414.0µs ± 0%13.6µs ± 0%−2.53%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-415.4µs ± 0%15.3µs ± 0%−0.66%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-419.1µs ± 0%17.9µs ± 0%−5.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4127µs ± 0%122µs ± 0%−3.47%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4132µs ± 0%130µs ± 0%−2.01%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4137µs ± 0%130µs ± 0%−4.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4171µs ± 0%150µs ± 0%−12.32%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4188µs ± 0%176µs ± 0%−6.71%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-415.5µs ± 0%14.0µs ± 0%−9.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-414.8µs ± 0%14.3µs ± 0%−2.92%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-415.6µs ± 0%14.9µs ± 0%−4.60%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-417.8µs ± 0%16.4µs ± 0%−7.81%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-421.5µs ± 0%20.0µs ± 0%−7.16%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4143µs ± 0%130µs ± 0%−9.37%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4142µs ± 0%135µs ± 0%−5.04%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4150µs ± 0%140µs ± 0%−7.24%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4158µs ± 0%154µs ± 0%−2.70%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4197µs ± 0%196µs ± 0%−0.58%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-445.7µs ± 0%41.6µs ± 0%−8.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-452.1µs ± 0%42.6µs ± 0%−18.12%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-454.9µs ± 0%43.8µs ± 0%−20.19%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-452.0µs ± 0%49.5µs ± 0%−4.85%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-465.3µs ± 0%60.6µs ± 0%−7.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4341µs ± 0%309µs ± 0%−9.24%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4337µs ± 0%312µs ± 0%−7.36%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4365µs ± 0%320µs ± 0%−12.12%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4403µs ± 0%363µs ± 0%−10.10%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4486µs ± 0%458µs ± 0%−5.66%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-444.7µs ± 0%41.1µs ± 0%−7.87%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-451.0µs ± 0%40.7µs ± 0%−20.23%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-448.7µs ± 0%43.4µs ± 0%−10.91%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-456.6µs ± 0%49.2µs ± 0%−13.06%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-465.8µs ± 0%60.7µs ± 0%−7.71%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4328µs ± 0%306µs ± 0%−6.77%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4332µs ± 0%317µs ± 0%−4.37%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4358µs ± 0%326µs ± 0%−8.95%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4389µs ± 0%366µs ± 0%−6.02%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4494µs ± 0%463µs ± 0%−6.24%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4116µs ± 0%110µs ± 0%−5.22%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4115µs ± 0%111µs ± 0%−4.20%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4118µs ± 0%112µs ± 0%−4.71%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4121µs ± 0%115µs ± 0%−5.01%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4135µs ± 0%129µs ± 0%−3.88%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-41.20ms ± 0%1.10ms ± 0%−8.29%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-41.15ms ± 0%1.11ms ± 0%−3.45%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-41.17ms ± 0%1.14ms ± 0%−2.46%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-41.34ms ± 0%1.31ms ± 0%−2.09%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4112µs ± 0%105µs ± 0%−6.57%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4111µs ± 0%104µs ± 0%−6.46%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4113µs ± 0%106µs ± 0%−5.55%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4118µs ± 0%111µs ± 0%−5.72%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4157µs ± 0%126µs ± 0%−19.42%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-41.13ms ± 0%1.05ms ± 0%−7.09%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.14ms ± 0%1.05ms ± 0%−8.07%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-41.15ms ± 0%1.07ms ± 0%−6.63%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-41.32ms ± 0%1.14ms ± 0%−13.28%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-41.30ms ± 0%1.26ms ± 0%−2.59%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-48.95µs ± 0%8.53µs ± 0%−4.70%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-49.55µs ± 0%8.82µs ± 0%−7.66%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-410.8µs ± 0%10.4µs ± 0%−3.64%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-414.1µs ± 0%13.8µs ± 0%−2.49%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-486.9µs ± 0%84.9µs ± 0%−2.30%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-488.0µs ± 0%87.6µs ± 0%−0.41%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-497.3µs ± 0%92.2µs ± 0%−5.21%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4118µs ± 0%109µs ± 0%−8.16%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4157µs ± 0%142µs ± 0%−9.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4126µs ± 0%124µs ± 0%−1.75%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4128µs ± 0%125µs ± 0%−2.17%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4132µs ± 0%130µs ± 0%−1.85%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.25ms ± 0%1.22ms ± 0%−2.12%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.28ms ± 0%1.28ms ± 0%−0.02%(p=1.000 n=1+1)
 
❌ See Worse Results...
time/opdelta
_Collection_UserSimple_CreateMany_Sync_0_100-4217ms ± 0%218ms ± 0%+0.60%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4235µs ± 0%239µs ± 0%+1.57%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-41.22ms ± 0%1.24ms ± 0%+1.03%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-48.10µs ± 0%8.11µs ± 0%+0.12%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4123µs ± 0%127µs ± 0%+3.09%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4124µs ± 0%126µs ± 0%+1.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.25ms ± 0%1.26ms ± 0%+0.52%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.21ms ± 0%1.25ms ± 0%+3.10%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-41.27ms ± 0%1.30ms ± 0%+1.96%(p=1.000 n=1+1)
 
✨ See Unchanged Results...
time/opdelta
 
🐋 See Full Results...
develop.txtcurrent.txt
time/opdelta
pkg:collection goos:linux goarch:amd64
_Collection_UserSimple_CreateMany_Sync_0_10-411.2ms ± 0%10.8ms ± 0%−3.52%(p=1.000 n=1+1)
_Collection_UserSimple_CreateMany_Sync_0_100-4217ms ± 0%218ms ± 0%+0.60%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_10-49.72ms ± 0%9.61ms ± 0%−1.08%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_100-498.4ms ± 0%97.3ms ± 0%−1.09%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Sync_0_1000-4981ms ± 0%972ms ± 0%−0.91%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_100-444.1ms ± 0%43.1ms ± 0%−2.38%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_1000-4442ms ± 0%421ms ± 0%−4.83%(p=1.000 n=1+1)
_Collection_UserSimple_Create_Async_0_10000-44.49s ± 0%4.35s ± 0%−3.25%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_10_10-4321µs ± 0%321µs ± 0%−0.11%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_100_100-43.50ms ± 0%3.36ms ± 0%−4.17%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_1000-438.6ms ± 0%36.2ms ± 0%−6.05%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_10-4358µs ± 0%344µs ± 0%−3.71%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Sync_1000_100-43.69ms ± 0%3.62ms ± 0%−1.93%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_10_10-4235µs ± 0%239µs ± 0%+1.57%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_100_100-41.81ms ± 0%1.72ms ± 0%−4.86%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_1000-423.4ms ± 0%21.8ms ± 0%−6.57%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_10-4259µs ± 0%250µs ± 0%−3.81%(p=1.000 n=1+1)
_Collection_UserSimple_Read_Async_1000_100-41.84ms ± 0%1.72ms ± 0%−6.32%(p=1.000 n=1+1)
pkg:query/simple goos:linux goarch:amd64
_Query_UserSimple_Query_Sync_10-4352µs ± 0%354µs ± 0%+0.36%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_100-41.14ms ± 0%1.10ms ± 0%−3.69%(p=1.000 n=1+1)
_Query_UserSimple_Query_Sync_1000-49.02ms ± 0%8.45ms ± 0%−6.41%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_10-4448µs ± 0%418µs ± 0%−6.74%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_100-41.22ms ± 0%1.18ms ± 0%−2.70%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithFilter_Sync_1000-49.41ms ± 0%8.79ms ± 0%−6.59%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_10-4407µs ± 0%386µs ± 0%−5.24%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_100-4501µs ± 0%430µs ± 0%−14.22%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithLimitOffset_Sync_1000-4457µs ± 0%432µs ± 0%−5.49%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_10-4646µs ± 0%643µs ± 0%−0.51%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_100-4682µs ± 0%608µs ± 0%−10.78%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithMultiLookup_Sync_1000-4676µs ± 0%630µs ± 0%−6.73%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_10-4441µs ± 0%402µs ± 0%−9.01%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_100-41.25ms ± 0%1.19ms ± 0%−5.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSort_Sync_1000-49.64ms ± 0%9.06ms ± 0%−6.04%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_10-4333µs ± 0%288µs ± 0%−13.61%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_100-4314µs ± 0%291µs ± 0%−7.25%(p=1.000 n=1+1)
_Query_UserSimple_Query_WithSingleLookup_Sync_1000-4299µs ± 0%289µs ± 0%−3.07%(p=1.000 n=1+1)
pkg:storage goos:linux goarch:amd64
_Storage_Simple_Read_Sync_1_10/ValueSize:0064-412.5µs ± 0%12.1µs ± 0%−3.20%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0128-413.3µs ± 0%12.4µs ± 0%−6.86%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0256-414.0µs ± 0%13.6µs ± 0%−2.53%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:0512-415.4µs ± 0%15.3µs ± 0%−0.66%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_10/ValueSize:1024-419.1µs ± 0%17.9µs ± 0%−5.90%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0064-4127µs ± 0%122µs ± 0%−3.47%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0128-4132µs ± 0%130µs ± 0%−2.01%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0256-4137µs ± 0%130µs ± 0%−4.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:0512-4171µs ± 0%150µs ± 0%−12.32%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_1_100/ValueSize:1024-4188µs ± 0%176µs ± 0%−6.71%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0064-415.5µs ± 0%14.0µs ± 0%−9.72%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0128-414.8µs ± 0%14.3µs ± 0%−2.92%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0256-415.6µs ± 0%14.9µs ± 0%−4.60%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:0512-417.8µs ± 0%16.4µs ± 0%−7.81%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_10/ValueSize:1024-421.5µs ± 0%20.0µs ± 0%−7.16%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0064-4143µs ± 0%130µs ± 0%−9.37%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0128-4142µs ± 0%135µs ± 0%−5.04%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0256-4150µs ± 0%140µs ± 0%−7.24%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:0512-4158µs ± 0%154µs ± 0%−2.70%(p=1.000 n=1+1)
_Storage_Simple_Read_Sync_100_100/ValueSize:1024-4197µs ± 0%196µs ± 0%−0.58%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0064-445.7µs ± 0%41.6µs ± 0%−8.98%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0128-452.1µs ± 0%42.6µs ± 0%−18.12%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0256-454.9µs ± 0%43.8µs ± 0%−20.19%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:0512-452.0µs ± 0%49.5µs ± 0%−4.85%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_10/ValueSize:1024-465.3µs ± 0%60.6µs ± 0%−7.18%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0064-4341µs ± 0%309µs ± 0%−9.24%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0128-4337µs ± 0%312µs ± 0%−7.36%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0256-4365µs ± 0%320µs ± 0%−12.12%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:0512-4403µs ± 0%363µs ± 0%−10.10%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_0_100/ValueSize:1024-4486µs ± 0%458µs ± 0%−5.66%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0064-444.7µs ± 0%41.1µs ± 0%−7.87%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0128-451.0µs ± 0%40.7µs ± 0%−20.23%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0256-448.7µs ± 0%43.4µs ± 0%−10.91%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:0512-456.6µs ± 0%49.2µs ± 0%−13.06%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_10/ValueSize:1024-465.8µs ± 0%60.7µs ± 0%−7.71%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0064-4328µs ± 0%306µs ± 0%−6.77%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0128-4332µs ± 0%317µs ± 0%−4.37%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0256-4358µs ± 0%326µs ± 0%−8.95%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:0512-4389µs ± 0%366µs ± 0%−6.02%(p=1.000 n=1+1)
_Storage_Simple_WriteMany_Sync_100_100/ValueSize:1024-4494µs ± 0%463µs ± 0%−6.24%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0064-4116µs ± 0%110µs ± 0%−5.22%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0128-4115µs ± 0%111µs ± 0%−4.20%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0256-4118µs ± 0%112µs ± 0%−4.71%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:0512-4121µs ± 0%115µs ± 0%−5.01%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_10/ValueSize:1024-4135µs ± 0%129µs ± 0%−3.88%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0064-41.20ms ± 0%1.10ms ± 0%−8.29%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0128-41.15ms ± 0%1.11ms ± 0%−3.45%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0256-41.17ms ± 0%1.14ms ± 0%−2.46%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:0512-41.22ms ± 0%1.24ms ± 0%+1.03%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_0_100/ValueSize:1024-41.34ms ± 0%1.31ms ± 0%−2.09%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0064-4112µs ± 0%105µs ± 0%−6.57%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0128-4111µs ± 0%104µs ± 0%−6.46%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0256-4113µs ± 0%106µs ± 0%−5.55%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:0512-4118µs ± 0%111µs ± 0%−5.72%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_10/ValueSize:1024-4157µs ± 0%126µs ± 0%−19.42%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0064-41.13ms ± 0%1.05ms ± 0%−7.09%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0128-41.14ms ± 0%1.05ms ± 0%−8.07%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0256-41.15ms ± 0%1.07ms ± 0%−6.63%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:0512-41.32ms ± 0%1.14ms ± 0%−13.28%(p=1.000 n=1+1)
_Storage_Simple_Write_Sync_100_100/ValueSize:1024-41.30ms ± 0%1.26ms ± 0%−2.59%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0064-48.10µs ± 0%8.11µs ± 0%+0.12%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0128-48.95µs ± 0%8.53µs ± 0%−4.70%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0256-49.55µs ± 0%8.82µs ± 0%−7.66%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:0512-410.8µs ± 0%10.4µs ± 0%−3.64%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_10_10/ValueSize:1024-414.1µs ± 0%13.8µs ± 0%−2.49%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0064-486.9µs ± 0%84.9µs ± 0%−2.30%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0128-488.0µs ± 0%87.6µs ± 0%−0.41%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0256-497.3µs ± 0%92.2µs ± 0%−5.21%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:0512-4118µs ± 0%109µs ± 0%−8.16%(p=1.000 n=1+1)
_Storage_Simple_Txn_Read_Sync_100_100/ValueSize:1024-4157µs ± 0%142µs ± 0%−9.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0064-4123µs ± 0%127µs ± 0%+3.09%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0128-4124µs ± 0%126µs ± 0%+1.56%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0256-4126µs ± 0%124µs ± 0%−1.75%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:0512-4128µs ± 0%125µs ± 0%−2.17%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_10_1_10/ValueSize:1024-4132µs ± 0%130µs ± 0%−1.85%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0064-41.25ms ± 0%1.26ms ± 0%+0.52%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0128-41.25ms ± 0%1.22ms ± 0%−2.12%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0256-41.21ms ± 0%1.25ms ± 0%+3.10%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:0512-41.28ms ± 0%1.28ms ± 0%−0.02%(p=1.000 n=1+1)
_Storage_Simple_Txn_Iterator_Sync_100_1_100/ValueSize:1024-41.27ms ± 0%1.30ms ± 0%+1.96%(p=1.000 n=1+1)
 

Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

Added some thoughts

cli/cli.go Outdated
Comment on lines 57 to 64
for _, cobraError := range cobraErrors {
if strings.HasPrefix(err.Error(), cobraError) {
if usageErr := rootCmd.Usage(); usageErr != nil {
log.FeedbackFatalE(ctx, "error displaying usage help", usageErr)
}
}
}
log.FeedbackErrorE(ctx, "DefraDB error", err)
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion: I'm not a fan of "DefraDB error" as a prefix here.

Additionally, there should be a difference between execution error and usage error. At the moment, it feels centered around usage error.

If it is a usage error, the prefix should indicate so, and should be logged before the Usage Help.

The original line log.FeedbackError(ctx, fmt.Sprintf("%s", err)) is prob helpful, maybe with slight modification for the execution error. It lets the error stand on its own.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback.

FeedbackErrorE is used to support the inclusion of stacktrace if that's desired, and it requires a prefix, and includes the error message (and stacktrace) as KVs. It could be updated if the internal errors pkg would allow access to the stacktrace.

I've updated.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure why you say it requires a prefix. Do you equate the message param to a prefix? Also, why would you want to have access to the stacktrace?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By prefix I meant message param, yes.

For consistency, as the rest of logging gives stacktraces on demand. A user might want to obtain stacktraces from the top-level returned error too.

Copy link
Collaborator

Choose a reason for hiding this comment

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

This can be done already. Just use:

fmt.Printf("%+v", err)

to get the stacktrace

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks for the info Fred. i knew about it but had forgotten

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated with Fred's feedback

Copy link
Collaborator

@fredcarle fredcarle left a comment

Choose a reason for hiding this comment

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

LGTM

cli/cli.go Outdated
Comment on lines 60 to 64
if cfg.Log.Stacktrace {
log.FeedbackError(ctx, fmt.Sprintf("%+v", err))
} else {
log.FeedbackError(ctx, err.Error())
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

question: I'm not sure I understand why you are doing this. Why not keep a message string and let the logger handle displaying the error's stacktrace?

Copy link
Contributor Author

@orpheuslummis orpheuslummis Sep 20, 2022

Choose a reason for hiding this comment

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

two currently conflicting goals:

  • have consistent log output formats across defradb
  • pleasant human experience using the program

for this PR it's best to prioritize have consistent log output formats across defradb, so reverted back.

in upcoming CLI work i'll resolve these currently conflicting goals ...

@orpheuslummis orpheuslummis force-pushed the orpheus/feat/cli-usage-on-user-error branch from 053c9f7 to 3c7e4e2 Compare September 20, 2022 17:33
Copy link
Member

@jsimnz jsimnz left a comment

Choose a reason for hiding this comment

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

LGTM!

@orpheuslummis orpheuslummis merged commit c967b9b into develop Sep 20, 2022
@orpheuslummis orpheuslummis deleted the orpheus/feat/cli-usage-on-user-error branch September 20, 2022 20:54
shahzadlone pushed a commit to shahzadlone/defradb that referenced this pull request Feb 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
action/no-benchmark Skips the action that runs the benchmark. area/cli Related to the CLI binary
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: systematic printing of usage on user error
4 participants