nextcloud / nextcloud/desktop

CLI account setup only supports one sync folder per invocation

Open
#9,966 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
3.9k
Forks
1k
Avg merge
1d 21h
Merged PRs (30d)
127

Description

## Problem

The command-line account setup feature (`--userid`, `--apppassword`, `--serverurl`, `--localdirpath`, `--remotedirpath`) currently has two limitations that make it impossible to configure more than one sync folder:

### 1. Repeated `--localdirpath` / `--remotedirpath` arguments are silently ignored

In `src/gui/accountsetupcommandlinemanager.cpp`, each argument is stored in a single `QString` member variable (`_localDirPath`, `_remoteDirPath`). Passing the same flag multiple times simply overwrites the previous value — only the last pair survives into the setup job.

### 2. A second invocation is rejected because the account already exists

`src/gui/accountsetupfromcommandlinejob.cpp` checks whether the account (`userid@hostname`) is already registered and exits with code 1 if so. This means there is no way to add a second sync folder to an already-configured account via the CLI — not in a single invocation, and not by running the app a second time.

## Expected behaviour

It should be possible to configure multiple sync folders for the same account in one CLI invocation, e.g.:

```
nextcloud \
--userid alice \
--apppassword secret \
--serverurl https://cloud.example.com \
--localdirpath ~/Documents --remotedirpath /Documents \
--localdirpath ~/Photos --remotedirpath /Photos
```

## Suggested fix

1. Change `_localDirPath` and `_remoteDirPath` in `AccountSetupCommandLineManager` from `QString` to `QList`, accumulating each flag value instead of overwriting.
2. In `AccountSetupFromCommandLineJob`, when the account already exists, skip account creation and proceed directly to folder setup instead of aborting.
3. Iterate over all requested folder pairs and call `setupLocalSyncFolder` for each one.

A working implementation is available as a pull request.

## Affected files

- `src/gui/accountsetupcommandlinemanager.h` / `.cpp`
- `src/gui/accountsetupfromcommandlinejob.h` / `.cpp`

Contributor guide

Open the contributing guide

Research direction

Start with src/gui/accountsetupcommandlinemanager.h/.cpp and src/gui/accountsetupfromcommandlinejob.h/.cpp to trace how folder arguments are collected and how existing accounts are handled. Confirm the command accepts multiple local/remote folder pairs, supports adding folders to an existing account, and completes setup for every pair.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli, desktop
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.