Skip to content

Support linux#17

Merged
brasic merged 8 commits intoBlakeWilliams:mainfrom
brasic:xclip
Oct 29, 2022
Merged

Support linux#17
brasic merged 8 commits intoBlakeWilliams:mainfrom
brasic:xclip

Conversation

@brasic
Copy link
Collaborator

@brasic brasic commented Oct 15, 2022

This adds support for running rdm server on linux machines by:

  • replacing macos-specific clipboard and URL-opening commands with an abstraction and using build constraints to select the correct implementation. Specifically pbcopy/pbpaste becomes xclip and open becomes xdg-open. One advantage of this approach is that the binary now only builds on platforms where it is capable of running.
  • fixing a path concatenation bug that caused illegal log paths to be generated.

Cheers!

edit: By request, 47d1953 also introduces a new interface for all OS-specific functionality. I called it hostservice.Service hostservice.Runner with a default implementation called hostservice.HostService.

On my ubuntu laptop the prior code fails as follows because
`os.TempDir` is "/tmp" and not "/tmp/".

    repos/rdm $ ./remote-development-manager server
    panic: open /tmprdm.log: permission denied

    goroutine 1 [running]:
    github.com/blakewilliams/remote-development-manager/internal/cmd.newServerCmd.func1(0xc000120000?, {0x7e8618?, 0x0?, 0x0?})
            /home/brasic/repos/rdm/internal/cmd/server.go:25 +0x45e
    github.com/spf13/cobra.(*Command).execute(0xc000120000, {0xb06210, 0x0, 0x0})
            /home/brasic/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:860 +0x663
    github.com/spf13/cobra.(*Command).ExecuteC(0xacd500)
            /home/brasic/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:974 +0x3b4
    github.com/spf13/cobra.(*Command).Execute(...)
            /home/brasic/go/pkg/mod/github.com/spf13/cobra@v1.3.0/command.go:902
    github.com/blakewilliams/remote-development-manager/internal/cmd.Execute({0x898a38, 0xc00018c040})
            /home/brasic/repos/rdm/internal/cmd/root.go:32 +0x207
    main.main()
            /home/brasic/repos/rdm/main.go:30 +0x159
Extracted most of macosClipboard into commandClipboard, which as a
platform-agnostic class that can handle any copy/paste command.

Added build-tagged files with build constraints for darwin and linux
respectively to specify pbcopy/pbpaste and xclip respectively.

Linux has multiple clipboards but I've chosen to use the one mapped to
Ctrl-C / Ctrl-V. Possibly in the future this could be configurable.
On linux xdg-open is the standard command to open URLs:

  * xdg-open - Open a URI in the user's preferred application that
    handles the respective URI or file type

`open` exists but it has different semantics than on macos (for example,
cannot handle URLS

Use the same build-tag mechanism to change the constant depending on
which platform we are on.  Unsupported platforms will be a build error.
@BlakeWilliams
Copy link
Owner

BlakeWilliams commented Oct 16, 2022

Oh, I think we'll want to update the README too, since it specifies that linux support isn't implemented yet.

@brasic
Copy link
Collaborator Author

brasic commented Oct 29, 2022

Oh, I think we'll want to update the README too, since it specifies that linux support isn't implemented yet.

Fixed in 87db441!

Carl Brasic and others added 3 commits October 29, 2022 14:24
Co-authored-by: Blake Williams <blakewilliams@github.com>
Co-authored-by: Blake Williams <blakewilliams@github.com>
Copy link
Owner

@BlakeWilliams BlakeWilliams left a comment

Choose a reason for hiding this comment

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

LGTM! Feel free to merge when you're ready.

@brasic brasic merged commit 12f91f9 into BlakeWilliams:main Oct 29, 2022
@brasic brasic deleted the xclip branch October 29, 2022 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants