Skip to content

Commit

Permalink
add protofile retrieving
Browse files Browse the repository at this point in the history
it only gets protofiles.  Callers are not generated
  • Loading branch information
Elli610 committed Aug 16, 2023
1 parent bab8ee1 commit 3834792
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions packages/massa-proto-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { Command } from 'commander';
import { MassaCustomType, extractTypes } from '@massalabs/as-transformer';
import * as dotenv from 'dotenv';
import { existsSync, mkdirSync } from 'fs';
import path from 'path';

// Load .env file content into process.env
dotenv.config();
const program = new Command();
Expand Down Expand Up @@ -43,9 +45,9 @@ if (!publicApi) {
async function run() {
const args = program.opts();
let files: ProtoFile[] = [];
let mode = args['gen'];
let address = args['addr'];
let out = args['out'];
let mode: string = args['gen'];
let address: string = args['addr'];
let out: string = args['out'];

if (mode === '' || address === '' || publicApi === undefined) {
program.help();
Expand All @@ -57,6 +59,17 @@ async function run() {
mkdirSync(out);
}

// if mode is 'get-protofile', we only need to fetch the proto files and save them
if (mode === 'get-protofile') {
const folderName = address.slice(-10);
// check if the folder exists
if (!existsSync(path.join(out, folderName))) {
mkdirSync(path.join(out, folderName));
}
await getProtoFiles([address], out + '/' + folderName, publicApi);
return;
}

// call sc client to fetch protos
const mpFiles: MassaProtoFile[] = await getProtoFiles(
[address],
Expand Down

0 comments on commit 3834792

Please sign in to comment.