Skip to content

chore: refactor the canister status/info/show commands - #225

Merged
raymondk merged 14 commits into
mainfrom
rk/canister-list-show
Dec 11, 2025
Merged

raymondk merged 14 commits into
mainfrom
rk/canister-list-show

Conversation

@raymondk

Copy link
Copy Markdown
Collaborator
# remove
icp canister info  # covered by status also not showing public info
icp canister show  # covered by project show and canister status

# keep
icp project show
icp canister list [--environment <env>]
icp canister status [<canister|principal>] [--environment <env>] [--network <net>]
icp canister settings show <canister|principal> [--environment <env>] [--network <net>]


#
# icp project show
#
# This will print the rendered manifest in yaml

icp project show
icp project show | yq -y '.networks'

# It's not exactly one to one so you can do this
icp project show | yq -y '.canisters["frontend"]'

#
# icp canister list
# - Requires a project context
# - will just list the names of canister in that environment

#
# icp canister status
#
#   by default will output canister id and the status for all canisters
#   if the status cannot be fetched, it will display a message
#   if the caller is not a controller it will fallback on fetching public
#   info from the state tree
#
# switches: 
# -i, --id-only
#   only display canister ids (will not go to the network)
#   this can throw an error if the canister has not been created
# -p, --public
#   Show only public info - skips trying to get the status from the 
#   management canister and instead looks up public info in the state
#   tree.
# --json 
#   output in json

## status for this canister (project required)
icp canister status <name>
## status for all the canisters in the project (project required)
icp canister status
## show the list of canister ids only   
icp canister status -i

## status for principal
icp canister status <principal> --network mainnet
icp canister status <principal> --network mainnet --json | jq ".controllers"
icp canister status my-frontend | jq ".settings"

# output format:
# :warning: we'll just make all the numbers strings because some of the can get too
# large 

# As a controller
{
  "id": "txyno-ch777-77776-aaaaq-cai",
  "status": "Running",
  "controllers": [
    "2vxsx-fae"
  ],
  "settings": {
    "compute_allocation": "0",
    "memory_allocation": "0",
    "freezing_threshold": "2592000",
    "reserved_cycles_limit": "5_000_000_000_000",
    "wasm_memory_limit": "3221225472",
    "wasm_memory_threshold": "0",
    "log_visibility": "controllers"
  },
  "environment_variables": [
    {
      "name": "PUBLIC_CANISTER_ID:backend",
      "value": "tqzl2-p7777-77776-aaaaa-cai"
    },
    {
      "name": "PUBLIC_CANISTER_ID:frontend",
      "value": "txyno-ch777-77776-aaaaq-cai"
    }
  ],
  "module_hash": "0xb312a16c3179cf8384afa852e468c1333b7439d4c5a39f26df69b12320f629f8",
  "memory_size": "2750192",
  "cycles": "1492916307316",
  "reserved_cycles": "0",
  "idle_cycles_burned_per_day": "28104807",
  "query_stats": {
    "calls": "0",
    "instructions": "0",
    "req_payload_bytes": "0",
    "res_payload_bytes": "0"
  }
}

# with -p or if not a control
{
  "id": "txyno-ch777-77776-aaaaq-cai",
  "controllers": [
    "2vxsx-fae"
  ],
  "module_hash": "0xb312a16c3179cf8384afa852e468c1333b7439d4c5a39f26df69b12320f629f8"
}

#
# icp canister settings show <canister>
#
# This will be similar to status, but a canister/principal is required
# switches:
# --json
#   output in json
#
# Output will have the same format as
# icp canister status <canister> | jq ".settings"

@raymondk
raymondk force-pushed the rk/canister-list-show branch from 62b1a43 to 8938d58 Compare December 10, 2025 23:29
@raymondk
raymondk force-pushed the rk/canister-list-show branch from 1e7aaa2 to 3bf3585 Compare December 11, 2025 00:58
@raymondk
raymondk marked this pull request as ready for review December 11, 2025 20:19
@raymondk
raymondk requested a review from a team as a code owner December 11, 2025 20:19
#[allow(clippy::large_enum_variant)]
pub(crate) enum Command {
/// Display a canister's settings
/// Show the status of a canister. By default this queries the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This whole paragraph is shown in icp canister settings help. Double linebreak after the first sentence prevents that.


if reject.error_code.as_deref() != Some(E_NOT_A_CONTROLLER) {
// We don't know this error code
bail!("Error looking up canister {cid}: {:?}", reject.error_code);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also include the reject message

@raymondk
raymondk enabled auto-merge (squash) December 11, 2025 21:26
@raymondk
raymondk merged commit 55b8921 into main Dec 11, 2025
40 checks passed
@raymondk
raymondk deleted the rk/canister-list-show branch December 11, 2025 21:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants