question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

--api command line argument only applies AFTER subcommand

See original GitHub issue

The Issue

If I use --api argument before start it has no effect. Only using --api after the start command works

Steps to reproduce

Run lbrynet --api 127.0.0.1:5279 start and lbrynet ignores this setting and uses localhost:5279 instead.

Expected behaviour

--api should work before and after the subcommand. This is how the --help says it should work. Or, altenatively remove the ability to specify --api before the subcommand.

Actual behaviour

lbrynet@4fee7df790bf:/$ lbrynet --version
lbrynet 0.36.0

lbrynet@4fee7df790bf:/$ lbrynet --help   
Usage:  lbrynet [-v] [--api HOST:PORT] [--config FILE] COMMAND ...

An interface to the LBRY Network.

Options:
  --help             Show this help message and exit.
  -v, --version      Show lbrynet CLI version and exit.
  --api HOST:PORT    Host name and port for lbrynet daemon API.
  --config FILE      Path to configuration file.

Grouped Commands:
  COMMAND
    account          Create, modify and inspect wallet accounts.
    address          List, generate and verify addresses.
    blob             Blob management.
    channel          Create, update, abandon and list your channel claims.
    claim            List and search all types of claims.
    comment          Create and list comments.
    file             File management.
    peer             DHT / Blob Exchange peer commands.
    settings         Settings management.
    stream           Create, update, abandon, list and inspect your stream
                     claims.
    support          Create, list and abandon all types of supports.
    sync             Wallet synchronization.
    transaction      Transaction management.
    utxo             Unspent transaction management.

Commands:
  COMMAND
    start            Start LBRY Network interface.
    stop             Stop lbrynet API server.
    get              Download stream from a LBRY name.
    publish          Create or update a stream claim at a given name (use
                     'stream create/update' for more control).
    resolve          Get the claim that a URL refers to.
    block_show       Get contents of a block
    routing_table_get
                     Get DHT routing information
    status           Get daemon status
    version          Get lbrynet API server version information

Run 'lbrynet COMMAND --help' for more information on a command or group.

lbrynet@4fee7df790bf:/$ lbrynet --api 127.0.0.1:5279 start
2019-05-01 14:43:10,521 INFO     lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon
2019-05-01 14:43:10,521 INFO     lbrynet.extras.daemon.Daemon:397: Platform: {
  "processor": "x86_64",
  "python_version": "3.7.1",
  "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-debian-buster-sid",
  "os_release": "4.19.34-1-MANJARO",
  "os_system": "Linux",
  "lbrynet_version": "0.36.0",
  "build": "release",
  "distro": {
    "id": "ubuntu",
    "version": "18.04",
    "version_parts": {
      "major": "18",
      "minor": "04",
      "build_number": ""
    },
    "like": "debian",
    "codename": "bionic"
  },
  "desktop": "Unknown"
}
2019-05-01 14:43:10,986 ERROR    lbrynet.extras.daemon.Daemon:407: lbrynet API failed to bind TCP localhost:5279 for listening. Daemon is already running or this port is already in use by another application.


lbrynet@4fee7df790bf:/$ lbrynet start --api 127.0.0.1:5279
2019-05-01 14:43:15,435 INFO     lbrynet.extras.daemon.Daemon:395: Starting LBRYNet Daemon
2019-05-01 14:43:15,436 INFO     lbrynet.extras.daemon.Daemon:397: Platform: {
  "processor": "x86_64",
  "python_version": "3.7.1",
  "platform": "Linux-4.19.34-1-MANJARO-x86_64-with-debian-buster-sid",
  "os_release": "4.19.34-1-MANJARO",
  "os_system": "Linux",
  "lbrynet_version": "0.36.0",
  "build": "release",
  "distro": {
    "id": "ubuntu",
    "version": "18.04",
    "version_parts": {
      "major": "18",
      "minor": "04",
      "build_number": ""
    },
    "like": "debian",
    "codename": "bionic"
  },
  "desktop": "Unknown"
}
2019-05-01 14:43:15,884 INFO     lbrynet.extras.daemon.Daemon:404: lbrynet API listening on TCP 127.0.0.1:5279
2019-05-01 14:43:16,032 INFO     lbrynet.extras.daemon.Components:561: detecting external ip
2019-05-01 14:43:16,033 INFO     lbrynet.extras.daemon.exchange_rate_manager:212: Starting exchange rate manager
2019-05-01 14:43:16,034 INFO     lbrynet.extras.daemon.Components:78: Loading databases
2019-05-01 14:43:16,036 INFO     torba.client.basedatabase:187: connecting to database: /home/lbrynet/.local/share/lbry/lbrynet/lbrynet.sqlite
2019-05-01 14:43:16,145 INFO     torba.client.basenetwork:88: Successfully connected to SPV wallet server: lbryumx1.lbry.io:50001
2019-05-01 14:43:16,178 INFO     lbrynet.extras.daemon.Components:194: remote height: 560415, local height: 216905
2019-05-01 14:43:16,396 WARNING  lbrynet.extras.daemon.Components:144: s3 appears to have corrupted header

Internal Use

Acceptance Criteria

Definition of Done

  • Tested against acceptance criteria
  • Tested against the assumptions of user story
  • The project builds without errors
  • Unit tests are written and passing
  • Tests on devices/browsers listed in the issue have passed
  • QA performed & issues resolved
  • Refactoring completed
  • Any configuration or build changes documented
  • Documentation updated
  • Peer Code Review performed

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
eukreigncommented, May 1, 2019

Okay, i’m fine with that, don’t know when we’ll get to it though. PRs welcome.

0reactions
eukreigncommented, May 1, 2019

See my comment to your PR.

To be honest, this seems like an extremely minor issue given the much bigger issues still left to tackle on the project. I’d err on the side of leaving this as-is and not adding additional technical debt (unless there is an elegant solution to all this with a clean implementation).

99.99% of users will never even know about this issue, some may not even think it’s an issue (especially if the doc strings are updated).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Command-line syntax overview for System.CommandLine
System. CommandLine has an ArgumentArity struct for defining arity, with the following values:
Read more >
Clikt - Common Options With Subcommands
This allows you to specify all options after the subcommand name. ... Similar to javac , Clikt supports loading command line parameters from...
Read more >
CommandLine (picocli 4.7.0 API)
Returns whether options can have parameter values that match subcommand names or aliases, or whether such values should be rejected with a missing...
Read more >
Java command line parser with subcommands that have ...
1 Answer 1 ... picocli supports nested subcommands to arbitrary depth. The main command defines global options, each following level of nested commands...
Read more >
argparse — Parser for command-line options, arguments and ...
The add_argument() method. Define how a single command-line argument should be parsed. Each parameter has its own more detailed description below, but in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found