entropyxyz / cli

CLI utility to ease interactions with an Entropy network.
GNU Affero General Public License v3.0
5 stars 0 forks source link

CLI should check `path` given to Deploy Program before erroring. #138

Open johnnymatthews opened 1 week ago

johnnymatthews commented 1 week ago

If you give the Deploy Program function a path that doesn't exist, the CLI errors out and exits:

? Select Action Deploy Program
? Select your action: Deploy
2024-06-25 16:55:31        REGISTRY: Unknown signed extensions ValidateConfirmRegistered found, treating them as no-effect
2024-06-25 16:55:31        API/INIT: RPC methods not decorated: chainSpec_v1_chainName, chainSpec_v1_genesisHash, chainSpec_v1_properties
? Please provide the path to your program: /this/path/does/not/exist
? Does your program have a configuration file? No
Error: ENOENT: no such file or directory, open '/this/path/does/not/exist'
    at Object.openSync (node:fs:573:18)
    at readFileSync (node:fs:452:35)
    at deployProgram (/home/io/Code/entropy/cli/src/flows/DeployPrograms/index.ts:52:35)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.devPrograms [as Deploy Program] (/home/io/Code/entropy/cli/src/flows/DeployPrograms/index.ts:33:3)
    at async main (/home/io/Code/entropy/cli/src/index.ts:89:30) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/this/path/does/not/exist'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

In the above example I gave the path /this/path/does/not/exist which doesn't exist on my system. It'd be nice for the CLI to check whether or not the path exists. If it does, move onto the next step. If it doesn't, tell the user the CLI can't find the path and ask for it again (or give the user the option to exist this function).

This issue stems from the main branch.