-
Notifications
You must be signed in to change notification settings - Fork 17
feat: file system support for ls, mkdir, rm, push, pull and get app path #228
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
gmegidish
wants to merge
18
commits into
main
Choose a base branch
from
feat-working-with-filesystem
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
c057ae1
feat: add app filesystem access commands (apps fs, apps path)
gmegidish 684e431
feat: implement android pull and fix ls/pull to not require bundle-id
gmegidish 570ecbb
feat: implement android push and update README with filesystem commands
gmegidish d0f9ef6
fix: use exec-out for app container pull to avoid CRLF corruption on …
gmegidish f2bae42
feat: implement android mkdir (-p) and rm (-r) for fs commands
gmegidish 6e8afde
docs: add mkdir and rm examples to README
gmegidish 387a115
feat: implement iOS simulator filesystem commands
gmegidish f9db748
refactor: clean code and architecture review fixes
gmegidish 6f6eca8
chore: remove stray file
gmegidish fd2f81f
refactor: remove bundleID from PushFile/PullFile interface
gmegidish 883006f
feat: validate local file exists before push
gmegidish e178dc4
chore: remove stray file
gmegidish 489c073
feat: implement device.fs.* and device.apps.path JSON-RPC handlers
gmegidish defc32a
test: add Android fs operations to emulator test suite
gmegidish 35fcbbd
refactor: extract runAsArgs helper and apply Go best practices
gmegidish 6f4f4a5
fix: apply clean-code review fixes
gmegidish dfe4aa3
Merge remote-tracking branch 'origin/main' into feat-working-with-fil…
gmegidish 1098f8c
fixed lint
gmegidish File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| package cli | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "strings" | ||
|
|
||
| "github.com/mobile-next/mobilecli/commands" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| var fsCmd = &cobra.Command{ | ||
| Use: "fs", | ||
| Short: "Access device filesystem", | ||
| Long: `Push, pull, list, and manage files on a device or in an app's container.`, | ||
| } | ||
|
|
||
| var fsPushCmd = &cobra.Command{ | ||
| Use: "push <local-path> <remote-path>", | ||
| Short: "Push a file to the device or into an app's container", | ||
| Args: cobra.ExactArgs(2), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| req := commands.FsPushRequest{ | ||
| DeviceID: deviceId, | ||
| LocalPath: args[0], | ||
| RemotePath: args[1], | ||
| } | ||
| response := commands.FsPushCommand(req) | ||
| printJson(response) | ||
| if response.Status == "error" { | ||
| return fmt.Errorf("%s", response.Error) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| var fsPullCmd = &cobra.Command{ | ||
| Use: "pull <remote-path> <local-path>", | ||
| Short: "Pull a file from the device or from an app's container", | ||
| Args: cobra.ExactArgs(2), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| req := commands.FsPullRequest{ | ||
| DeviceID: deviceId, | ||
| RemotePath: args[0], | ||
| LocalPath: args[1], | ||
| } | ||
| response := commands.FsPullCommand(req) | ||
| printJson(response) | ||
| if response.Status == "error" { | ||
| return fmt.Errorf("%s", response.Error) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| var fsLsCmd = &cobra.Command{ | ||
| Use: "ls [bundle-id] [remote-path]", | ||
| Short: "List files on the device or in an app's container", | ||
| Args: cobra.RangeArgs(0, 2), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| var bundleID, remotePath string | ||
| if len(args) == 1 && strings.HasPrefix(args[0], "/") { | ||
| remotePath = args[0] | ||
| } else { | ||
| bundleID = args[0] | ||
| if len(args) == 2 { | ||
| remotePath = args[1] | ||
| } | ||
| } | ||
| req := commands.FsListRequest{ | ||
| DeviceID: deviceId, | ||
| BundleID: bundleID, | ||
| RemotePath: remotePath, | ||
| } | ||
| response := commands.FsListCommand(req) | ||
| printJson(response) | ||
| if response.Status == "error" { | ||
| return fmt.Errorf("%s", response.Error) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| var ( | ||
| fsMkdirParents bool | ||
| fsRmRecursive bool | ||
| ) | ||
|
|
||
| var fsMkdirCmd = &cobra.Command{ | ||
| Use: "mkdir [bundle-id] <remote-path>", | ||
| Short: "Create a directory on the device or in an app's container", | ||
| Args: cobra.RangeArgs(1, 2), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| var bundleID, remotePath string | ||
| if len(args) == 1 { | ||
| remotePath = args[0] | ||
| } else { | ||
| bundleID = args[0] | ||
| remotePath = args[1] | ||
| } | ||
| req := commands.FsMkdirRequest{ | ||
| DeviceID: deviceId, | ||
| BundleID: bundleID, | ||
| RemotePath: remotePath, | ||
| Parents: fsMkdirParents, | ||
| } | ||
| response := commands.FsMkdirCommand(req) | ||
| printJson(response) | ||
| if response.Status == "error" { | ||
| return fmt.Errorf("%s", response.Error) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| var fsRmCmd = &cobra.Command{ | ||
| Use: "rm [bundle-id] <remote-path>", | ||
| Short: "Remove a file or directory on the device or in an app's container", | ||
| Args: cobra.RangeArgs(1, 2), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| var bundleID, remotePath string | ||
| if len(args) == 1 { | ||
| remotePath = args[0] | ||
| } else { | ||
| bundleID = args[0] | ||
| remotePath = args[1] | ||
| } | ||
| req := commands.FsRmRequest{ | ||
| DeviceID: deviceId, | ||
| BundleID: bundleID, | ||
| RemotePath: remotePath, | ||
| Recursive: fsRmRecursive, | ||
| } | ||
| response := commands.FsRmCommand(req) | ||
| printJson(response) | ||
| if response.Status == "error" { | ||
| return fmt.Errorf("%s", response.Error) | ||
| } | ||
| return nil | ||
| }, | ||
| } | ||
|
|
||
| func init() { | ||
| rootCmd.AddCommand(fsCmd) | ||
|
|
||
| fsCmd.AddCommand(fsPushCmd) | ||
| fsCmd.AddCommand(fsPullCmd) | ||
| fsCmd.AddCommand(fsLsCmd) | ||
| fsCmd.AddCommand(fsMkdirCmd) | ||
| fsCmd.AddCommand(fsRmCmd) | ||
|
|
||
| fsPushCmd.Flags().StringVar(&deviceId, "device", "", "ID of the target device") | ||
| fsPullCmd.Flags().StringVar(&deviceId, "device", "", "ID of the target device") | ||
| fsLsCmd.Flags().StringVar(&deviceId, "device", "", "ID of the target device") | ||
| fsMkdirCmd.Flags().StringVar(&deviceId, "device", "", "ID of the target device") | ||
| fsMkdirCmd.Flags().BoolVarP(&fsMkdirParents, "parents", "p", false, "Create parent directories as needed") | ||
| fsRmCmd.Flags().StringVar(&deviceId, "device", "", "ID of the target device") | ||
| fsRmCmd.Flags().BoolVarP(&fsRmRecursive, "recursive", "r", false, "Remove directories and their contents recursively") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify platform-support wording to avoid contradiction.
Line 227 limits support to Android/iOS Simulator, but Line 305 says binary-safe pull works on “all platforms.” Please align this phrasing (for example, “all supported platforms”) so expectations are clear.
🤖 Prompt for AI Agents