You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2020/02/29 01:12:32 UTC
[mynewt-imgmod] 07/08: New command: image extractbody
This is an automated email from the ASF dual-hosted git repository.
ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-imgmod.git
commit 0f5f9eaead163a6fa61fb4ed75613260b60a964b
Author: Christopher Collins <cc...@apache.org>
AuthorDate: Fri Feb 28 16:27:31 2020 -0800
New command: image extractbody
---
cli/image_cmds.go | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/cli/image_cmds.go b/cli/image_cmds.go
index 5aa1315..6ef308e 100644
--- a/cli/image_cmds.go
+++ b/cli/image_cmds.go
@@ -674,6 +674,25 @@ func runVerifyCmd(cmd *cobra.Command, args []string) {
}
}
+func runExtractBodyCmd(cmd *cobra.Command, args []string) {
+ if len(args) < 1 {
+ ImgmodUsage(cmd, nil)
+ }
+
+ imgFilename := args[0]
+ outFilename := args[1]
+
+ img, err := readImage(imgFilename)
+ if err != nil {
+ ImgmodUsage(cmd, err)
+ }
+
+ err = WriteFile(img.Body, outFilename)
+ if err != nil {
+ ImgmodUsage(nil, err)
+ }
+}
+
func AddImageCommands(cmd *cobra.Command) {
imageCmd := &cobra.Command{
Use: "image",
@@ -883,4 +902,12 @@ func AddImageCommands(cmd *cobra.Command) {
"", "Manifest file")
imageCmd.AddCommand(verifyCmd)
+
+ extractBodyCmd := &cobra.Command{
+ Use: "extractbody <image> <out-file>",
+ Short: "Extracts a Mynewt image's body",
+ Run: runExtractBodyCmd,
+ }
+
+ imageCmd.AddCommand(extractBodyCmd)
}