Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
arduino-cli
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Operations
Operations
Metrics
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
arduino-cli
Commits
cffc6b30
Commit
cffc6b30
authored
Aug 01, 2018
by
Cristian Maglie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added lib upgrade command
parent
154e95f7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
76 additions
and
5 deletions
+76
-5
commands/commands_test.go
commands/commands_test.go
+12
-5
commands/lib/lib.go
commands/lib/lib.go
+1
-0
commands/lib/upgrade.go
commands/lib/upgrade.go
+63
-0
No files found.
commands/commands_test.go
View file @
cffc6b30
...
...
@@ -238,17 +238,24 @@ func TestLibDownloadAndInstall(t *testing.T) {
require
.
Contains
(
t
,
string
(
d
),
"Audio@1.0.3"
)
require
.
Contains
(
t
,
string
(
d
),
"not installed"
)
// Uninstall (with version)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"uninstall"
,
"Audio@1.0.4"
)
// Upgrade libraries
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"upgrade"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Installed"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio"
)
require
.
Contains
(
t
,
string
(
d
),
"1.0.5"
)
// Uninstall (without version)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"uninstall"
,
"Audio"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Uninstalling"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio"
)
require
.
Contains
(
t
,
string
(
d
),
"1.0.
4
"
)
require
.
Contains
(
t
,
string
(
d
),
"1.0.
5
"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"list"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
NotContains
(
t
,
string
(
d
),
"Audio"
)
// Uninstall (with
out
version)
// Uninstall (with version)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"install"
,
"Audio@1.0.4"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio@1.0.4"
)
...
...
@@ -257,7 +264,7 @@ func TestLibDownloadAndInstall(t *testing.T) {
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio"
)
require
.
Contains
(
t
,
string
(
d
),
"1.0.4"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"uninstall"
,
"Audio"
)
exitCode
,
d
=
executeWithArgs
(
t
,
"lib"
,
"uninstall"
,
"Audio
@1.0.4
"
)
require
.
Zero
(
t
,
exitCode
,
"exit code"
)
require
.
Contains
(
t
,
string
(
d
),
"Uninstalling"
)
require
.
Contains
(
t
,
string
(
d
),
"Audio"
)
...
...
commands/lib/lib.go
View file @
cffc6b30
...
...
@@ -48,6 +48,7 @@ func InitCommand() *cobra.Command {
libCommand
.
AddCommand
(
initListCommand
())
libCommand
.
AddCommand
(
initSearchCommand
())
libCommand
.
AddCommand
(
initUninstallCommand
())
libCommand
.
AddCommand
(
initUpgradeCommand
())
libCommand
.
AddCommand
(
initUpdateIndexCommand
())
return
libCommand
}
commands/lib/upgrade.go
0 → 100644
View file @
cffc6b30
/*
* This file is part of arduino-cli.
*
* arduino-cli is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* As a special exception, you may use this file as part of a free software
* library without restriction. Specifically, if other files instantiate
* templates or use macros or inline functions from this file, or you compile
* this file and link it with other files to produce an executable, this
* file does not by itself cause the resulting executable to be covered by
* the GNU General Public License. This exception does not however
* invalidate any other reasons why the executable file might be covered by
* the GNU General Public License.
*
* Copyright 2017 ARDUINO AG (http://www.arduino.cc/)
*/
package
lib
import
(
"github.com/bcmi-labs/arduino-cli/arduino/libraries/librariesindex"
"github.com/bcmi-labs/arduino-cli/commands"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
func
initUpgradeCommand
()
*
cobra
.
Command
{
listCommand
:=
&
cobra
.
Command
{
Use
:
"upgrade"
,
Short
:
"Upgrades installed libraries."
,
Long
:
"This command ungrades all installed libraries to the latest available version."
+
"To upgrade a single library use the 'install' command."
,
Example
:
"arduino lib upgrade"
,
Args
:
cobra
.
NoArgs
,
Run
:
runUpgradeCommand
,
}
return
listCommand
}
func
runUpgradeCommand
(
cmd
*
cobra
.
Command
,
args
[]
string
)
{
lm
:=
commands
.
InitLibraryManager
(
nil
)
list
:=
listLibraries
(
lm
,
true
)
libReleases
:=
[]
*
librariesindex
.
Release
{}
for
_
,
upgradeDesc
:=
range
list
.
Libraries
{
libReleases
=
append
(
libReleases
,
upgradeDesc
.
Available
)
}
downloadLibraries
(
lm
,
libReleases
)
installLibraries
(
lm
,
libReleases
)
logrus
.
Info
(
"Done"
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment