Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Improve the arduino-app-cli version command by adding the "server version" #31#49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
martacarbone wants to merge9 commits intomain
base:main
Choose a base branch
Loading
fromcli_server_version

Conversation

@martacarbone
Copy link

@martacarbonemartacarbone commentedNov 6, 2025
edited
Loading

Motivation

When running arduino-app-cli version instead of only returning the version of the currently run executable (the CLI) we should also return the version of the server (the daemon/service running and waiting for HTTP API requests).

Change description

This change make a version request to the running daemon and adds the output to thearduino-app-cli version command.
It also adds "daemon_version" and rename "appName" to "name" from the json output.

Additional Notes

Test done with a daemon with version 8.8.8-server-dev running on port 8080. The output is:

% ./arduino-app-cli versionWarning: cannot get the running daemon version on localhost:8800Arduino App CLI version 0.0.0-dev
% ./arduino-app-cli version --port 8080Arduino App CLI version 0.0.0-devdaemon version: 8.8.8-server-dev
./arduino-app-cli version --format=json {  "name": "Arduino App CLI",  "version": "0.0.0-dev",  "warnings": [    "Warning: cannot get the running daemon version on localhost:8800\n"  ]}
% ./arduino-app-cli version --port 8080 --format=json{  "name": "Arduino App CLI",  "version": "0.0.0-dev",  "daemon_version": "8.8.8-server-dev"}
./arduino-app-cli version  --port 1234 Warning: cannot get the running daemon version on localhost:1234Arduino App CLI version 0.0.0-dev

The http server part is unaffected:

% curl http://localhost:8080/v1/version{"version":"8.8.8-server-dev"}

Reviewer checklist

  • PR addresses a single concern.
  • PR title and description are properly filled.
  • Changes will be merged inmain.
  • Changes are covered by tests.
  • Logging is meaningful in case of troubleshooting.

lucarin91 reacted with eyes emoji
@CLAassistant
Copy link

CLAassistant commentedNov 6, 2025
edited
Loading

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@lucarin91lucarin91 left a comment

Choose a reason for hiding this comment

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

Looks good, I added some minor suggestions to make it more readable (in my opinion)

@per1234per1234 added the enhancementNew feature or request labelNov 8, 2025
Copy link
Contributor

@dido18dido18 left a comment

Choose a reason for hiding this comment

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

I would rename theserverVersion intodaemonVersion all over the place

returnnet.JoinHostPort(h,p),nil
}

funcgetServerVersion(httpClient http.Client,urlstring)string {
Copy link
Contributor

Choose a reason for hiding this comment

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

It could be useful to log DEBUG/WARN message with the error of this check.

Proposal:
The function returns astring, error.
If there is an error, the caller logs it, assigns the "empty" daemon version and prints a generic "error on get daemon version" in the cli response.

}

ifdaemonVersion=="" {
returnresult,fmt.Errorf("cannot connect to %s",hostAndPort)
Copy link
Contributor

Choose a reason for hiding this comment

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

This hardcoded error could be misleading if it's not a connection error.
See the proposal to return the error and log it in the comment below

AppNamestring`json:"appName"`
Versionstring`json:"version"`
Namestring`json:"name"`
ClientVersionstring`json:"client_version"`
Copy link
Contributor

@dido18dido18Nov 10, 2025
edited
Loading

Choose a reason for hiding this comment

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

Thisclient_version is a breaking change in the JSON response.

Current:

GET http://127.0.0.1:8800/v1/version{"version":"v0.2.3"}

Proposal: leave theversion and add thename anddaemon_version

GET http://127.0.0.1:8800/v1/version{"name": "Arduino App CLI","version":"v0.2.3""daemon_version": "v0.2.3"  }

Comment on lines 136 to 137
serverMessage:=fmt.Sprintf("%s client version %s",
ProgramName,r.ClientVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
serverMessage:= fmt.Sprintf("%s client version %s",
ProgramName, r.ClientVersion)
serverMessage:=fmt.Sprintf("%s client version %s",ProgramName,r.ClientVersion)

Comment on lines 140 to 141
serverMessage=fmt.Sprintf("%s\ndaemon version: %s",
serverMessage,r.DaemonVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
serverMessage= fmt.Sprintf("%s\ndaemon version: %s",
serverMessage, r.DaemonVersion)
serverMessage=fmt.Sprintf("%s\ndaemon version: %s",serverMessage,r.DaemonVersion)


// Leverage the http.Client's RoundTripper
// to return a canned response and bypass network calls.
typeTripperfunc(*http.Request) (*http.Response,error)
Copy link
Contributor

Choose a reason for hiding this comment

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

I usually prefer using the httptest module instead of mocking the http client

Comment on lines +106 to +107
resultMessage=fmt.Sprintf("%s\ndaemon version: %s",
resultMessage,r.DaemonVersion)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit

Suggested change
resultMessage= fmt.Sprintf("%s\ndaemon version: %s",
resultMessage, r.DaemonVersion)
resultMessage=fmt.Sprintf("%s\ndaemon version: %s",resultMessage,r.DaemonVersion)

martacarboneand others added3 commitsNovember 11, 2025 10:59
Co-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>
Co-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>
Co-authored-by: Luca Rinaldi <l.rinaldi@arduino.cc>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@lucarin91lucarin91lucarin91 approved these changes

@dido18dido18dido18 approved these changes

+1 more reviewer

@alessio-peruginialessio-peruginialessio-perugini left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

enhancementNew feature or request

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Improve thearduino-app-cli version command by adding the "server version"

6 participants

@martacarbone@CLAassistant@lucarin91@alessio-perugini@dido18@per1234

[8]ページ先頭

©2009-2025 Movatter.jp