From fe2060b4e7fcfdfe3688d4f27201b4dc6c413d8b Mon Sep 17 00:00:00 2001 From: merlinz01 <158784988+merlinz01@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:22:45 -0500 Subject: [PATCH 1/2] add new FORMAT --- src/commands.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/commands.ts b/src/commands.ts index b836568..583f815 100644 --- a/src/commands.ts +++ b/src/commands.ts @@ -28,7 +28,7 @@ enum FormatType { LOWERCASE, UPPERCASE, SNIPPET, - CUSTOM + CUSTOM, } enum GuidGenerateType { @@ -161,6 +161,19 @@ const FORMATS: GuidPickFormat[] = [ }, type: FormatType.SNIPPET }, + { + named: true, + format: (g) => { + return util.format('const %s: GUID = GUID%s;', NAME_PLACEHOLDER, g.toString('structrs')); + }, + preface: (g) => { + return util.format('// %s\n', g.toString('braced')); + }, + epilogue: (g) => { + return '\n'; + }, + type: FormatType.SNIPPET + }, ]; /** From 68cc7532bd6c64152a3120e98edbd55a2ce8b6d4 Mon Sep 17 00:00:00 2001 From: merlinz01 <158784988+merlinz01@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:24:25 -0500 Subject: [PATCH 2/2] add new toString format --- src/guid.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/guid.ts b/src/guid.ts index ca607cf..182a465 100644 --- a/src/guid.ts +++ b/src/guid.ts @@ -90,6 +90,12 @@ export class Guid { b.toString('hex', 8, 9), b.toString('hex', 9, 10), b.toString('hex', 10, 11), b.toString('hex', 11, 12), b.toString('hex', 12, 13), b.toString('hex', 13, 14), b.toString('hex', 14, 15), b.toString('hex', 15, 16)); + } else if (format === 'structrs') { + return util.format('{data1: 0x%s, data2: 0x%s, data3: 0x%s, data4: [0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s, 0x%s]}', + b.toString('hex', 0, 4), b.toString('hex', 4, 6), b.toString('hex', 6, 8), + b.toString('hex', 8, 9), b.toString('hex', 9, 10), + b.toString('hex', 10, 11), b.toString('hex', 11, 12), b.toString('hex', 12, 13), + b.toString('hex', 13, 14), b.toString('hex', 14, 15), b.toString('hex', 15, 16)); } else if (format === 'braced' || format === 'b') { return util.format('{%s}', this.toString()); } else if (format === 'no-hyphen') {