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

Fixing outputFormatter and standardising STDOUT #50

Merged
merged 10 commits into from
Nov 8, 2023
Merged

Conversation

addievo
Copy link
Contributor

@addievo addievo commented Nov 2, 2023

Description

This PR builds upon #45

And aims to fix some issues which were not resolved in their entirety in #45.

These mainly include:

  1. Simplification of outputTableFormatter.
  2. Adding quotes back on stdout.
  3. Encode non-printable characters except spaces.

Fixed Issues

  1. Fixes CLI polish and fixes for deployment #44

Tasks

  • 1. Tidy up outputTableFormatter.
  • 2. Adding double quotes back on STDOUT.
  • 3. Encoding non-printable chars except spaces on STDOUT.
  • 4. Define and implement new encodeEscaped and encodeEscapedWrapped API for output character escape encoding

Final checklist

  • Domain specific tests
  • Full tests
  • Updated inline-comment documentation
  • Lint fixed
  • Squash and rebased
  • Sanity check the final build

@addievo addievo mentioned this pull request Nov 2, 2023
11 tasks
@ghost
Copy link

ghost commented Nov 2, 2023

👇 Click on the image for a new way to code review

Review these changes using an interactive CodeSee Map

Legend

CodeSee Map legend

@addievo addievo force-pushed the feature-stdout-fix branch from 970fbee to 8ff3fc6 Compare November 2, 2023 02:12
@addievo addievo requested a review from tegefaulkes November 2, 2023 02:14
@addievo addievo self-assigned this Nov 2, 2023
Copy link
Contributor

@tegefaulkes tegefaulkes left a comment

Choose a reason for hiding this comment

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

The code doesn't build. That needs to be fixed before merging.

It was broken in #45 too so I'm not sure why that was merged. You need to follow the merge checklist because it's there to catch this kind of problem. But it's fully ticked right now even though the build fails, why is that?

@CMCDragonkai
Copy link
Member

There was prior review commentary located here: #45 (comment).

@amydevs best to refer to the prior comments that @tegefaulkes made too.

@CMCDragonkai CMCDragonkai assigned amydevs and unassigned addievo Nov 3, 2023
@CMCDragonkai CMCDragonkai mentioned this pull request Nov 5, 2023
@amydevs amydevs force-pushed the feature-stdout-fix branch 5 times, most recently from 309d1d7 to fc9963e Compare November 6, 2023 05:23
@CMCDragonkai
Copy link
Member

This is conflicting with staging? You may need a rebase?

And also can you provide previews of what all these commands look like now?

@amydevs amydevs force-pushed the feature-stdout-fix branch 5 times, most recently from f6f3c21 to 8a78d50 Compare November 6, 2023 06:19
@amydevs amydevs force-pushed the feature-stdout-fix branch from c873e3c to ec4c097 Compare November 8, 2023 00:26
@amydevs
Copy link
Contributor

amydevs commented Nov 8, 2023

@amydevs are you going to change the vault ID generation?

It doesn't look right to me, the original code never encoded the tabs.

no, what i'm saying is that a lot of the commands were using \t before for spacing.

like this

data.push(
              `${vaultListMessage.vaultName}:\t${
                vaultListMessage.vaultIdEncoded
              }`,
            );

I've replaced it with spaces instead

data.push(
              `${vaultListMessage.vaultName}:${' '.repeat(4)}${
                vaultListMessage.vaultIdEncoded
              }`,
            );

ID generation never generated characters that had to be escaped.

@amydevs amydevs force-pushed the feature-stdout-fix branch from 547cc0f to 961cc81 Compare November 8, 2023 02:55
@amydevs
Copy link
Contributor

amydevs commented Nov 8, 2023

https://stackoverflow.com/questions/20585729/how-to-detect-if-nodes-process-stdout-is-being-piped

We might want to never escape when the output is being redirected btw, this will have to be done in another pr at some point if it is needed

@amydevs amydevs force-pushed the feature-stdout-fix branch 6 times, most recently from 4ac6577 to d7d35c7 Compare November 8, 2023 13:58
addievo and others added 10 commits November 9, 2023 01:01
fix: removed unneeded `arrayToAsyncIterable` utility function

fix: made handling of '' and `null` cells consistent in `outputTableFormatter`

fix: cleaned up tests in `utils.test.ts`

fix: condensed arbitraries in `utils.test.ts`

fix: removed unneeded concats of strings in `utils.test.ts`

fix: `outputTableFormatter` is no longer async and `outputFormatter` no longer can return `Promise<string>`

fix: cleaned up `outputFormatter` for `list` type

[ci-skip]
…adding in streaming usage

fix: moved positioning of `TableRow` and `TableOptions` type

[ci-skip]
…FormatterList`, `outputFormatterTable`, etc.)

chore: renamed instances of `formattedOutput` to `outputFormatted`

[ci-skip]
…ts/keys/certchain.test.ts` and `tests/keys/cert.test.ts`
…when strings are wrapped with `\"\"` double quotes

fix: fixed raw escape character encoding on `outputFormatter`

fix: encoding of quotes in `outputFormatter` is now correctly escaped

[ci-skip]
chore: lintfix

fix: removal of related tests to `encodeWrappedStrings`

feat: encoding is now enabled/disabled based on if the string contains any encodable content

feat: merged `encodeQuotes` and `encodePrintable` into `encodeEscaped`

fix: corrected `encodeEscape` and `decodeEscape` behaviour regarding quotes and unicode escape sequences

feat: tests for `encodeEscaped` and `decodeEscaped`

fix: inline documentation for `decodeEscaped`

fix: fixed expected formatting for `CommandScan` test in `vaults.test.ts`

[ci-skip]
@amydevs amydevs force-pushed the feature-stdout-fix branch from d7d35c7 to 37db593 Compare November 8, 2023 14:01
@amydevs
Copy link
Contributor

amydevs commented Nov 8, 2023

should be done, just wrote up new api for encoding escape characters. Please refer to this PR if it comes up

@amydevs amydevs merged commit 550c32f into staging Nov 8, 2023
@CMCDragonkai
Copy link
Member

What if there's other kinds non-printable characters? Usually when quoted in JS, they appear as slash unicodes. Also I was wondering if we could have just used the standard console.log and captured it's output somehow. JS seems to have native quoting when it comes to strings. Did you have a look?

@amydevs
Copy link
Contributor

amydevs commented Nov 9, 2023

What if there's other kinds non-printable characters? Usually when quoted in JS, they appear as slash unicodes. Also I was wondering if we could have just used the standard console.log and captured it's output somehow. JS seems to have native quoting when it comes to strings. Did you have a look?

native quoting only applies to the browser console, not the STDOUT in Node.JS

image

At the moment, I am also turning those \u characters into escaped versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

CLI polish and fixes for deployment
4 participants