fabric-samples/full-stack-asset-transfer-guide/applications/conga-cards/src/app.ts
jkneubuh a299e18e26
Moves the Full Stack Asset Transfer Development Guide to fabric-samples (#852)
* Import Full Stack Asset Transfer Guide at commit fb554befdbbeff9e69159b54fce0b811603f29c7

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update the workshop with a new WORKSHOP_PATH under fabric-samples

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Update the workshop with a new WORKSHOP_PATH under fabric-samples

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* missed a .git ignored directory on add

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Updates to run the workshop on the Apple M1

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Workaround for https://github.com/eslint/eslint/issues/15299 in the contract tslinter

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* Build an arch-specific CC images on M1

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* empty commit - force a build

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

* revert an accidental commit that was building the top-level asset-transfer as arm64

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>

Signed-off-by: Josh Kneubuhl <jkneubuh@us.ibm.com>
2022-11-10 10:40:27 -05:00

54 lines
1.4 KiB
TypeScript

/*
* Copyright contributors to the Hyperledgendary Full Stack Asset Transfer Guide project
*
* SPDX-License-Identifier: Apache-2.0
*/
import * as sourceMapSupport from 'source-map-support';
sourceMapSupport.install();
import { Command, commands } from './commands';
import { newGatewayConnection, newGrpcConnection } from './connect';
import { ExpectedError } from './expectedError';
async function main(): Promise<void> {
const commandName = process.argv[2];
const args = process.argv.slice(3);
const command = commands[commandName];
if (!command) {
printUsage();
throw new Error(`Unknown command: ${commandName}`);
}
await runCommand(command, args);
}
async function runCommand(command: Command, args: string[]): Promise<void> {
const client = await newGrpcConnection();
try {
const gateway = await newGatewayConnection(client);
try {
await command(gateway, args);
} finally {
gateway.close();
}
} finally {
client.close();
}
}
function printUsage(): void {
console.log('Arguments: <command> [<arg1> ...]');
console.log('Available commands:');
console.log(`\t${Object.keys(commands).sort().join('\n\t')}`);
}
main().catch(error => {
if (error instanceof ExpectedError) {
console.log(error);
} else {
console.error('\nUnexpected application error:', error);
process.exitCode = 1;
}
});