Anoma.Client.CLI (Anoma v0.34.0)

I implement the logic for the Anoma client commandline interface.

Usage

The executable expects the following arguments:

  • --node-host - The host of the remote node.
  • --node-port - The port of the remote node.
  • --node-id - The id of the remote node.

For example, assuming an Anoma node running on ip 'localhost' and port '4000', start the client with the following command.

./anoma_client --node-host localhost --node-port 4000 --node-id 123456

Running a node

Running a node can be done using the same repository. In an Elixir shell of the Anoma repo, run the following.

iex(1)> Anoma.Node.Examples.ENode.start_node(grpc_port: 8181)
%Anoma.Node.Examples.ENode{
  grpc_port: 8181,
  pid: #PID<0.353.0>,
  node_id: "110532251"
}

Use the value of grpc_port to point your client to the node.

The client will connect to the remote node and start listening for incoming connections on port 4000.

Building

To build the binary for the client run the following from the root of this repository.

mix do --app anoma_client escript.build

Summary

Functions

I parse the arguments into a keyword list and validate if all the arguments are present.

Given a list of arguments, I start a new connection to a remote node.

Given a keyword list, I check if all required arguments are present. I return a list of missing arguments if theyre not present.

Functions

main(args)

@spec main([String.t()]) :: any()

parse_args(args)

@spec parse_args([String.t()]) ::
  {:ok, Keyword.t()}
  | {:error, {:invalid_args, [String.t()]}}
  | {:error, {:missing_args, [atom()]}}

I parse the arguments into a keyword list and validate if all the arguments are present.

start_node(args)

@spec start_node(Keyword.t()) :: any()

Given a list of arguments, I start a new connection to a remote node.

Options

  • :node_host - The host of the remote node.
  • :node_port - The port of the remote node.
  • :node_id - The node id of the node to connect to.

validate_args(args)

@spec validate_args(Keyword.t()) ::
  {:ok, Keyword.t()} | {:error, {:missing_args, [atom()]}}

Given a keyword list, I check if all required arguments are present. I return a list of missing arguments if theyre not present.