Skip to content

Commit 7b4b493

Browse files
committed
Made some cli procedures available for other packages
Unfortunately we cannot limit the availability of the cli.core.* package to the cli.* packages, but they are now available as public API.
1 parent 151a1cd commit 7b4b493

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

cli/core/update_index.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func initUpdateIndexCommand() *cobra.Command {
4444
func runUpdateIndexCommand(cmd *cobra.Command, args []string) {
4545
inst := instance.CreateInstanceAndRunFirstUpdate()
4646
logrus.Info("Executing `arduino-cli core update-index`")
47+
UpdateIndex(inst)
48+
}
4749

50+
// UpdateIndex updates the index of platforms.
51+
func UpdateIndex(inst *rpc.Instance) {
4852
err := commands.UpdateIndex(context.Background(), &rpc.UpdateIndexRequest{Instance: inst}, output.ProgressBar())
4953
if err != nil {
5054
feedback.Error(err)

cli/lib/update_index.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ func initUpdateIndexCommand() *cobra.Command {
4444
func runUpdateIndexCommand(cmd *cobra.Command, args []string) {
4545
inst := instance.CreateInstanceAndRunFirstUpdate()
4646
logrus.Info("Executing `arduino-cli lib update-index`")
47+
UpdateIndex(inst)
48+
}
4749

50+
// UpdateIndex updates the index of libraries.
51+
func UpdateIndex(inst *rpc.Instance) {
4852
err := commands.UpdateLibrariesIndex(context.Background(), &rpc.UpdateLibrariesIndexRequest{
4953
Instance: inst,
5054
}, output.ProgressBar())

cli/lib/upgrade.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,17 @@ func initUpgradeCommand() *cobra.Command {
4646
func runUpgradeCommand(cmd *cobra.Command, args []string) {
4747
instance := instance.CreateAndInit()
4848
logrus.Info("Executing `arduino-cli lib upgrade`")
49+
Upgrade(instance, args)
50+
}
4951

52+
// Upgrade upgrades the specified libraries
53+
func Upgrade(instance *rpc.Instance, libraries []string) {
5054
var upgradeErr error
51-
if len(args) == 0 {
55+
if len(libraries) == 0 {
5256
req := &rpc.LibraryUpgradeAllRequest{Instance: instance}
5357
upgradeErr = lib.LibraryUpgradeAll(req, output.ProgressBar(), output.TaskProgress())
5458
} else {
55-
for _, libName := range args {
59+
for _, libName := range libraries {
5660
req := &rpc.LibraryUpgradeRequest{
5761
Instance: instance,
5862
Name: libName,

0 commit comments

Comments
 (0)