neo-project / neo

NEO Smart Economy
MIT License
3.47k stars 1.03k forks source link

Quality of life CLI options --config-file & --ignore-plugin-network #3337

Open ixje opened 3 months ago

ixje commented 3 months ago

Summary or problem description Switching between networks with neo-cli has always been a hassle because

  1. it automatically reads from config.json
  2. most plugins equally have a config.json in which a Network field is defined that must match the global config.json

This means that every time you wish to switch you must update the global config.json and all plugin config files, or duplicate the whole setup in another directory. Compare this to neo-go where you can specify a config file and the rest just works.

Do you have any solution you want to propose? I want to propose 2 command line options

  1. --config-file allows you to override which file is loaded as the global config
  2. --ignore-plugin-network allows you to ignore the Network field check e.g. https://github.com/neo-project/neo/blob/efbdc94c541ccc70c09e5dd745bb73e2160e6312/src/Plugins/ApplicationLogs/LogReader.cs#L72-L73

If the options are omitted the old behaviour will be used.

Where in the software does this update applies to?

cschuchardt88 commented 3 months ago

The current CLI can't do this at the moment. Environment.CommandLine won't work in plugins either. But will be noted.

ixje commented 3 months ago

Apparently --config was already added and I didn't realize it.

https://github.com/neo-project/neo/blob/efbdc94c541ccc70c09e5dd745bb73e2160e6312/src/Neo.CLI/CLI/MainService.CommandLine.cs#L26

So that leaves --ignore-plugin-network

Jim8y commented 3 months ago

console command currently only work on cli itself. ww can mark this and add it before the next version.

cschuchardt88 commented 3 months ago

All plugins will need to be updated as well.