[GH-ISSUE #427] Command line options (cli parameters) #3245

Closed
opened 2026-03-13 05:13:44 +03:00 by kerem · 23 comments
Owner

Originally created by @majkinetor on GitHub (May 27, 2023).
Original GitHub issue: https://github.com/1Remote/1Remote/issues/427

Originally assigned to: @majkinetor, @VShawn on GitHub.

1Remote should have several command line options that can be used for installation, startup and connection running.

  1. --(un)install
    Runs all of the (un)install-*** options
  2. --(un)install-desktop-shortcut
    (Un)Install desktop shortcut and exit
  3. --(un)install-startup
    (Un)Install registry startup entry and exit
  4. --start-minimized
    Run app minimized
  5. ULID:<connection-id> or <connection-name> or #<tag-name>
    Run app and imediatelly execute and/or focus connection name or tag. NOTE: we could have just one here if this is problematic (tag or single connection name)

Documentation

TODO (@majkinetor)

Examples

# Install everything - desktop shortcut and startup (over existing ones if found) and exit. Startup uses --miimized option
1remote.exe --install

# Remove desktop shortcut if found and exit
1remote.exe --uninstall-desktop-shortcut

# run tag #foo and connection 'bar'
1remote.exe #foo bar

#run long named connection
1remote.exe "foo bar baz" 

#run two connections by connection id
1remote.exe id:12 id:17

#run in the background
1remote.exe --start-minimized

#run and/or focus
1remote.exe

Details

Future work

After CLI options are done, here are the things that should be done in the subsequent tickets that I will create separatelly:

  1. On connection context menu - add desktop shortcut
  2. On connection bulk selection menu - add desktop shortcut to run selected connections
  3. On tag context menu - add desktop shortcut to run this tag
  4. On options menu - run automatically at OS startup (it will use --minimzed option)
    5. Start minimized should be removed as it is pointless

Install/Uninstall

We could expand this with some more but this is enough for the start IMO and to be able to have installation routine for #402.

I intentionally didn't want to introducd option for "all users", start menu entries and uninstall in "programs and files". The first two are IMO not needed - 1RM is not a kind of program that will be used by multiple users on single machine IMO (and if that is needed, each user could have its own portable copy), and since it doesn't have multiple runable items start menu entery is usless. We could add uninstall entery that will just call 1remote.exe --uninstall but it will leave files on the disk and it doesn't seem important. I think we could just add those in the GUI options, for example System integration tab in options that would enable user to run all those things that we will be able to do via CLI (after these are implemented) via convenient buttons and/or checkboxes.

Run minimized

Startup minimized is implemented the wrong way. 1RM should have an app argument that does that, which will then setup to be used in Windows registry. That way, when one runs 1Remote by hand or shortcut icon, it will show the main window, which is expected behavior.

Originally created by @majkinetor on GitHub (May 27, 2023). Original GitHub issue: https://github.com/1Remote/1Remote/issues/427 Originally assigned to: @majkinetor, @VShawn on GitHub. 1Remote should have several command line options that can be used for installation, startup and connection running. 1. [x] `--(un)install` Runs all of the (un)install-*** options 2. [x] `--(un)install-desktop-shortcut ` (Un)Install desktop shortcut and exit 3. [x] `--(un)install-startup` (Un)Install registry startup entry and exit 4. [x] `--start-minimized` Run app minimized 5. [x] `ULID:<connection-id>` or `<connection-name>` or `#<tag-name>` Run app and imediatelly execute and/or focus connection name or tag. NOTE: we could have just one here if this is problematic (tag or single connection name) ## Documentation TODO (@majkinetor) ## Examples ``` # Install everything - desktop shortcut and startup (over existing ones if found) and exit. Startup uses --miimized option 1remote.exe --install # Remove desktop shortcut if found and exit 1remote.exe --uninstall-desktop-shortcut # run tag #foo and connection 'bar' 1remote.exe #foo bar #run long named connection 1remote.exe "foo bar baz" #run two connections by connection id 1remote.exe id:12 id:17 #run in the background 1remote.exe --start-minimized #run and/or focus 1remote.exe ``` ## Details ## Future work After CLI options are done, here are the things that should be done in the subsequent tickets that I will create separatelly: 1. On connection context menu - add desktop shortcut 2. On connection bulk selection menu - add desktop shortcut to run selected connections 3. On tag context menu - add desktop shortcut to run this tag 4. On options menu - run automatically at OS startup (it will use --minimzed option) 5. Start minimized should be removed as it is pointless ### Install/Uninstall We could expand this with some more but this is enough for the start IMO and to be able to have installation routine for #402. I intentionally didn't want to introducd option for "all users", start menu entries and uninstall in "programs and files". The first two are IMO not needed - 1RM is not a kind of program that will be used by multiple users on single machine IMO (and if that is needed, each user could have its own portable copy), and since it doesn't have multiple runable items start menu entery is usless. We could add uninstall entery that will just call `1remote.exe --uninstall` but it will leave files on the disk and it doesn't seem important. I think we could just add those in the GUI options, for example _System integration_ tab in options that would enable user to run all those things that we will be able to do via CLI (after these are implemented) via convenient buttons and/or checkboxes. ### Run minimized Startup minimized is implemented the wrong way. 1RM should have an app argument that does that, which will then setup to be used in Windows registry. That way, when one runs 1Remote by hand or shortcut icon, it will show the main window, which is expected behavior.
Author
Owner

@majkinetor commented on GitHub (May 27, 2023):

There is small problem with this and winget - user will have to shutdown app first in order for it to get updated. But that is the same for all portable apps, its not specific to 1RM. There is no way to go around this as winget will first unpack the zip archive over existing location which will fail as exe is already in use. We could technically make -install option make 1RM to copy itself to another location and previously kill any running 1Remote.exe, but I am not sure if we should go those lengths at the moment (although its almost trivial to do).

Chocolatey package will shut down the app first and if it was started before, rerun it after update, so it doesn't have this problem. This can be done as choco uses pwsh script, feature that winget doesn't have.

<!-- gh-comment-id:1565369752 --> @majkinetor commented on GitHub (May 27, 2023): There is small problem with this and winget - user will have to shutdown app first in order for it to get updated. But that is the same for all portable apps, its not specific to 1RM. There is no way to go around this as winget will first unpack the zip archive over existing location which will fail as exe is already in use. We could technically make -install option make 1RM to copy itself to another location and previously kill any running 1Remote.exe, but I am not sure if we should go those lengths at the moment (although its almost trivial to do). Chocolatey package will shut down the app first and if it was started before, rerun it after update, so it doesn't have this problem. This can be done as choco uses pwsh script, feature that winget doesn't have.
Author
Owner

@majkinetor commented on GitHub (May 27, 2023):

As for some examples @VShawn , check up everything. It has CLI option for all installation routines, which I united via single option, but you could separate them too.

<!-- gh-comment-id:1565371432 --> @majkinetor commented on GitHub (May 27, 2023): As for some examples @VShawn , check up [everything](https://www.voidtools.com/support/everything/command_line_options/). It has CLI option for all installation routines, which I united via single option, but you could separate them too.
Author
Owner

@majkinetor commented on GitHub (May 27, 2023):

BTW, I would also add here some command line options regarding the running of specific connections. But I consider this to be lower priority task and could be also done in future. Something like:

  • -run #tag-foo
  • -run 'con name foo'

1Remote would accept multiple of those. This would enable 'create desktop shortcut` for specific connection(s).

<!-- gh-comment-id:1565373861 --> @majkinetor commented on GitHub (May 27, 2023): BTW, I would also add here some command line options regarding the running of specific connections. But I consider this to be lower priority task and could be also done in future. Something like: - `-run #tag-foo` - `-run 'con name foo' ` 1Remote would accept multiple of those. This would enable 'create desktop shortcut` for specific connection(s).
Author
Owner

@VShawn commented on GitHub (May 28, 2023):

Startup minimized is implemented the wrong way. 1RM should have an app argument that does that

You are right :)

-run 'con name foo'

I designed this feature in the prototype of PRM. users could create shortcuts in the right-click context menu of the connection. then they could search and open connections through tools like Everything. Now, we can still keep the action of creating shortcuts in context menu

P.S.

I'd like that there will be a todo list like #401, for each issue after the discussion is completed, so that we can confirm the work to be done. After all, these tickets may not be started for some time, and without a todo list, we may forget the objectives.

<!-- gh-comment-id:1565959850 --> @VShawn commented on GitHub (May 28, 2023): > Startup minimized is implemented the wrong way. 1RM should have an app argument that does that You are right :) > `-run 'con name foo'` I designed this feature in the prototype of PRM. users could create shortcuts in the right-click context menu of the connection. then they could search and open connections through tools like Everything. Now, we can still keep the action of creating shortcuts in context menu P.S. I'd like that there will be a todo list like #401, for each issue after the discussion is completed, so that we can confirm the work to be done. After all, these tickets may not be started for some time, and without a todo list, we may forget the objectives.
Author
Owner

@majkinetor commented on GitHub (May 28, 2023):

Yeah, you are right about todo list. However, it can be done only after the discussion, so I'll make sure we have it in the opening post.

<!-- gh-comment-id:1565994669 --> @majkinetor commented on GitHub (May 28, 2023): Yeah, you are right about todo list. However, it can be done only after the discussion, so I'll make sure we have it in the opening post.
Author
Owner

@majkinetor commented on GitHub (May 28, 2023):

Yeah, you are right about todo list. However, it can be done only after the discussion, so I'll make sure we have it in the opening post.

<!-- gh-comment-id:1565994669 --> @majkinetor commented on GitHub (May 28, 2023): Yeah, you are right about todo list. However, it can be done only after the discussion, so I'll make sure we have it in the opening post.
Author
Owner

@majkinetor commented on GitHub (May 29, 2023):

@VShawn, I edited the first post. Please take a look and if you have comments or questions or think something should be modified, bring it on.

<!-- gh-comment-id:1567270733 --> @majkinetor commented on GitHub (May 29, 2023): @VShawn, I edited the first post. Please take a look and if you have comments or questions or think something should be modified, bring it on.
Author
Owner

@VShawn commented on GitHub (May 30, 2023):

I think it's good :)

<!-- gh-comment-id:1567666409 --> @VShawn commented on GitHub (May 30, 2023): I think it's good :)
Author
Owner

@VShawn commented on GitHub (Jun 12, 2023):

connection-name or #tag i think it should be case insensitive?

And the command will start all connections named connection-name from all databases?

from this point I wanna add a protocol like path/to/1Remote.exe id:xxxxx to start a specific connection for enable 'create desktop shortcut for specific connection(s).`.

<!-- gh-comment-id:1586941878 --> @VShawn commented on GitHub (Jun 12, 2023): `connection-name` or `#tag` i think it should be case insensitive? And the command will start all connections named `connection-name` from all databases? from this point I wanna add a protocol like `path/to/1Remote.exe id:xxxxx` to start a specific connection for `enable 'create desktop shortcut` for specific connection(s).`.
Author
Owner

@majkinetor commented on GitHub (Jun 12, 2023):

connection-name or #tag i think it should be case insensitive?

Yes

And the command will start all connections named connection-name from all databases?
from this point I wanna add a protocol like path/to/1Remote.exe id:xxxx

Well, you can have multiple same named connections even in the local database. So yes, all should be started if that is the case I guess.

Yes, we should have connection id, but I would use it in addition to connection name as it is not CLI friendly - majority of the people won't have duplicate connection names anyway. I will add it to the above list.

<!-- gh-comment-id:1587031910 --> @majkinetor commented on GitHub (Jun 12, 2023): > connection-name or #tag i think it should be case insensitive? Yes > And the command will start all connections named connection-name from all databases? > from this point I wanna add a protocol like path/to/1Remote.exe id:xxxx Well, you can have multiple same named connections even in the local database. So yes, all should be started if that is the case I guess. Yes, we should have connection id, but I would use it in addition to connection name as it is not CLI friendly - majority of the people won't have duplicate connection names anyway. I will add it to the above list.
Author
Owner

@majkinetor commented on GitHub (Jun 12, 2023):

BTW, the id:15 is also a valid name. Not sure that we need id: prefix then.

So 1remote 15 17 vs 1remote id:15 id:17.

Perhaps we should forbid naming connections by number ?

<!-- gh-comment-id:1587039391 --> @majkinetor commented on GitHub (Jun 12, 2023): BTW, the `id:15` is also a valid name. Not sure that we need `id:` prefix then. So `1remote 15 17` vs `1remote id:15 id:17`. Perhaps we should forbid naming connections by number ?
Author
Owner

@VShawn commented on GitHub (Jun 14, 2023):

I've done all the task in this ticke? Do I need to continue adding a desktop shortcut for connection in this ticket?

<!-- gh-comment-id:1591063035 --> @VShawn commented on GitHub (Jun 14, 2023): I've done all the task in this ticke? Do I need to continue adding a desktop shortcut for connection in this ticket?
Author
Owner

@majkinetor commented on GitHub (Jun 14, 2023):

Nah, this is for CLI options only.

<!-- gh-comment-id:1591806049 --> @majkinetor commented on GitHub (Jun 14, 2023): Nah, this is for CLI options only.
Author
Owner

@majkinetor commented on GitHub (Jun 14, 2023):

Nah, this is for CLI options only.

<!-- gh-comment-id:1591806049 --> @majkinetor commented on GitHub (Jun 14, 2023): Nah, this is for CLI options only.
Author
Owner

@majkinetor commented on GitHub (Jun 14, 2023):

Lets keep this open until I test it and add documentation.

<!-- gh-comment-id:1591808139 --> @majkinetor commented on GitHub (Jun 14, 2023): Lets keep this open until I test it and add documentation.
Author
Owner

@VShawn commented on GitHub (Jun 15, 2023):

auto build is donw since I import the COM Windows Script Host Object Model in order to creat a desktop shortcut

var shortcut = new IWshRuntimeLibrary.WshShell().CreateShortcut(shortcutPath);
shortcut.IconLocation =
shortcut.TargetPath = Process.GetCurrentProcess().MainModule!.FileName!;
shortcut.WorkingDirectory = Environment.CurrentDirectory;
shortcut.Arguments = "";
shortcut.Description = Assert.APP_DISPLAY_NAME;
shortcut.Save();

I can build it on my dev env, but if failed with github action.

Build Error from github action: The task "ResolveComReference" is not supported on the .NET Core version of MSBuild.B

So you are not able to test cli until I find out how to fix github action.

<!-- gh-comment-id:1592154805 --> @VShawn commented on GitHub (Jun 15, 2023): auto build is donw since I import the COM `Windows Script Host Object Model` in order to creat a desktop shortcut ``` var shortcut = new IWshRuntimeLibrary.WshShell().CreateShortcut(shortcutPath); shortcut.IconLocation = shortcut.TargetPath = Process.GetCurrentProcess().MainModule!.FileName!; shortcut.WorkingDirectory = Environment.CurrentDirectory; shortcut.Arguments = ""; shortcut.Description = Assert.APP_DISPLAY_NAME; shortcut.Save(); ``` I can build it on my dev env, but if failed with github action. Build Error from github action: `The task "ResolveComReference" is not supported on the .NET Core version of MSBuild.`B So you are not able to test cli until I find out how to fix github action.
Author
Owner

@majkinetor commented on GitHub (Jun 15, 2023):

What about this one.

Other then that, you could embed nircmd (license allows it). Its around 100KB.

<!-- gh-comment-id:1592363709 --> @majkinetor commented on GitHub (Jun 15, 2023): What about [this](https://www.nuget.org/packages/WindowsShortcutFactory/) one. Other then that, you could embed [nircmd](https://nircmd.nirsoft.net/shortcut.html) (license allows it). Its around 100KB.
Author
Owner

@VShawn commented on GitHub (Jun 17, 2023):

It was eventually built

<!-- gh-comment-id:1595604283 --> @VShawn commented on GitHub (Jun 17, 2023): It was eventually built
Author
Owner

@majkinetor commented on GitHub (Jun 21, 2023):

I tested it and everything works. Maybe we want to have /? as standardized but its not teribly important as we will have web docs.

<!-- gh-comment-id:1601360944 --> @majkinetor commented on GitHub (Jun 21, 2023): I tested it and everything works. Maybe we want to have `/?` as standardized but its not teribly important as we will have web docs.
Author
Owner

@majkinetor commented on GitHub (Jun 21, 2023):

Actually reopening this while docs are not done.

<!-- gh-comment-id:1601361951 --> @majkinetor commented on GitHub (Jun 21, 2023): Actually reopening this while docs are not done.
Author
Owner

@majkinetor commented on GitHub (Jun 21, 2023):

Ahh, this is awesome:

image

image

<!-- gh-comment-id:1601394953 --> @majkinetor commented on GitHub (Jun 21, 2023): Ahh, this is awesome: ![image](https://github.com/1Remote/1Remote/assets/85767/ade7bb06-0562-47dc-be15-a16ab0bf6053) ![image](https://github.com/1Remote/1Remote/assets/85767/c532d1e0-b7a0-48ba-8711-82d4cdc7bd3d)
Author
Owner

@majkinetor commented on GitHub (Jun 21, 2023):

Ahh, this is awesome:

image

image

<!-- gh-comment-id:1601394953 --> @majkinetor commented on GitHub (Jun 21, 2023): Ahh, this is awesome: ![image](https://github.com/1Remote/1Remote/assets/85767/ade7bb06-0562-47dc-be15-a16ab0bf6053) ![image](https://github.com/1Remote/1Remote/assets/85767/c532d1e0-b7a0-48ba-8711-82d4cdc7bd3d)
Author
Owner

@VShawn commented on GitHub (Jun 22, 2023):

You even changed the icon of the shortcut. I also considered mapping the shortcut icon to the server icon when developing, but the icon of connections stored in 1RM is in PNG format while shortcuts only support ICO icons.

<!-- gh-comment-id:1602024289 --> @VShawn commented on GitHub (Jun 22, 2023): You even changed the icon of the shortcut. I also considered mapping the shortcut icon to the server icon when developing, but the icon of connections stored in 1RM is in PNG format while shortcuts only support ICO icons.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/1Remote#3245
No description provided.