### Basic CMake Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cpp/test/projectFolderNatvis/CMakeLists.txt Sets the minimum CMake version and project name. This is a standard starting point for any CMake project. ```cmake cmake_minimum_required(VERSION 3.16) project(HelloQt LANGUAGES CXX) ``` -------------------------------- ### Install go-licenses Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Install the `go-licenses` tool using `go install` for generating third-party license reports. ```bash $ go install github.com/google/go-licenses@latest ``` -------------------------------- ### Install Tools with run.sh Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Use the `install-tools` command in `run.sh` to install necessary go packages and tools for building and license updates. ```bash ./run.sh install-tools ./run.sh build ``` -------------------------------- ### Install Goreleaser Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Install the goreleaser tool using `go install` to manage project packaging and deployment. ```bash $ go install github.com/goreleaser/goreleaser/v2@latest ``` -------------------------------- ### Standard Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-qml/test/projectFolderQmlDebug/CMakeLists.txt Applies standard Qt project settings. This simplifies common configuration tasks. ```cmake qt_standard_project_setup() ``` -------------------------------- ### Qt Standard Project Setup (Qt 6.5+) Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/src/assets/templates/projects/cpp/qtquick/CMakeLists.txt Configures standard project settings for Qt 6.5 and later, ensuring compatibility and proper setup. ```cmake {{ if ge $mininumQtVersionFloat 6.5 }} qt_standard_project_setup(REQUIRES {{ .minimumQtVersion }}) {{ end }} ``` -------------------------------- ### Install Target Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/tests/e2e/expected_outputs/projects_cpp_qtquick/CMakeLists.txt Defines installation rules for the executable, specifying destinations for bundles, libraries, and runtimes based on standard directories. ```cmake include(GNUInstallDirs) install(TARGETS appprojects_cpp_qtquick BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Qt Standard Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/tutorials/QuickAddressBook/CMakeLists.txt Applies standard Qt project settings. Ensure your Qt version is compatible. ```cmake qt_standard_project_setup(REQUIRES 6.8) ``` -------------------------------- ### Project Installation Rules Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/tests/e2e/expected_outputs/projects_cpp_qwidget/CMakeLists.txt Defines installation rules for the executable, placing it in appropriate directories based on the operating system and build type. ```cmake include(GNUInstallDirs) install(TARGETS projects_cpp_qwidget BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Configuring Installation Rules Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/src/assets/templates/projects/cpp/qwidget/CMakeLists.txt Defines where the built target should be installed on the system. This includes specifying destinations for bundles, libraries, and runtime executables. ```cmake include(GNUInstallDirs) install(TARGETS {{ .name }} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Install Target Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/tutorials/QuickAddressBook/CMakeLists.txt Defines installation rules for the application executable. It specifies the destination directories for bundles, libraries, and runtime files based on standard GNU install directories. ```cmake include(GNUInstallDirs) install(TARGETS appQuickAddressBook BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### Qt Project Setup and Executable Definition Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/tests/e2e/expected_outputs/projects_cpp_qwidget/CMakeLists.txt Sets up standard Qt project conventions and defines the main executable target along with its source files. ```cmake qt_standard_project_setup() qt_add_executable(projects_cpp_qwidget main.cpp mainwindow.cpp mainwindow.h mainwindow.ui ) ``` -------------------------------- ### Install Target Executable Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/src/assets/templates/projects/cpp/qtquick/CMakeLists.txt Configures installation rules for the target executable, specifying destinations for bundles, libraries, and runtime files. ```cmake include(GNUInstallDirs) install(TARGETS {{ $target }} BUNDLE DESTINATION . LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} ) ``` -------------------------------- ### QML File Template Example Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Templates.md A simple example of a QML file template that uses the project name variable. No prompt.yml is needed as no user input is required. ```qml import QtQuick Rectangle { width: 640 height: 480 color: "#ffffff" Text { anchors.centerIn: parent text: "Hello, {{ .name }}!" } } ``` -------------------------------- ### Start Qt CLI REST Server Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Use this command to start the REST API server. It supports both Unix Domain Sockets (UDS) and TCP/IP, with options for custom socket names, ports, and automatic exit on idle. ```bash qtcli server start [OPTIONS] ``` ```bash # start server with Unix Domain Socket (default): $ qtcli server start ``` ```bash # start server with custom socket name $ qtcli server start --socket my-custom-socket ``` ```bash # start server with TCP on port 8080 $ qtcli server start --tcp --port 8080 ``` ```bash # start server with auto-exit on idle $ qtcli server start --exit-on-idle --heartbeat 5s ``` -------------------------------- ### Picker Input Type Example Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Templates.md Example of a 'picker' type prompt, allowing users to select from a list of options. Requires the 'items' property. ```yaml - id: baseClass type: picker question: "Select base class:" default: QObject items: - text: QObject - text: QWidget - text: QMainWindow - text: QQuickItem ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/src/assets/templates/projects/cpp/qwidget/CMakeLists.txt Sets the minimum CMake version, project name, and C++ standard. Ensures the C++ standard is required and enabled. ```cmake cmake_minimum_required(VERSION 3.16) project({{ .name }} VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Generate Third-Party Licenses Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md After installing `go-licenses`, navigate to the `src/` directory and run `go-licenses report` with a template file to generate the `ThirdPartyNotices.txt`. ```bash $ cd src $ go-licenses report . --template ../others/ThirdPartyNotices.tpl --ignore qtcli > ../ThirdPartyNotices.txt ``` -------------------------------- ### Starting the server Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Starts a REST API server. It can be configured to use Unix Domain Sockets (UDS) or TCP, with options for specifying socket names, ports, and idle timeouts. ```APIDOC ## qtcli server start ### Description Starts a REST API server. By default, it uses Unix Domain Sockets (UDS). Options allow for TCP usage, custom socket names, port specification, and automatic exit on inactivity. ### Method CLI Command ### Parameters #### Options - `--socket ` (string) - Optional - Specify UDS socket name. - `--tcp` (boolean) - Optional - Use TCP instead of UDS. Defaults to false. - `--port ` (integer) - Optional - Specify TCP port. Defaults to 8080. Only used with `--tcp`. - `--exit-on-idle` (boolean) - Optional - Exit the server automatically after inactivity. Defaults to false. - `--heartbeat ` (string) - Optional - Heartbeat interval for idle detection (e.g., `5s`, `1m`). Defaults to 10s. ### Examples ```bash # start server with Unix Domain Socket (default): $ qtcli server start # start server with custom socket name $ qtcli server start --socket my-custom-socket # start server with TCP on port 8080 $ qtcli server start --tcp --port 8080 # start server with auto-exit on idle $ qtcli server start --exit-on-idle --heartbeat 5s ``` ``` -------------------------------- ### AddressBook Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/tutorials/AddressBook/CMakeLists.txt Configures the CMake version, project name, version, and C++ standard. Ensures C++17 compliance. ```cmake cmake_minimum_required(VERSION 3.16) project(AddressBook VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/tests/e2e/expected_outputs/projects_cpp_qwidget/CMakeLists.txt Sets the minimum CMake version and project name with version. Specifies C++17 standard and makes it required. ```cmake cmake_minimum_required(VERSION 3.16) project(projects_cpp_qwidget VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Basic CMake Project Setup Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/src/assets/templates/projects/cpp/qtquick/CMakeLists.txt Sets the minimum CMake version and project name. It also configures C++ standard requirements. ```cmake cmake_minimum_required(VERSION 3.16) project(example VERSION 0.1 LANGUAGES CXX) set(CMAKE_CXX_STANDARD_REQUIRED ON) ``` -------------------------------- ### Find Qt6 Components Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/tutorials/QuickAddressBook/CMakeLists.txt Locates the Qt6 installation and imports necessary components like Quick and Gui. The REQUIRED keyword ensures the build fails if Qt6 is not found. ```cmake find_package(Qt6 6.8 REQUIRED COMPONENTS Quick Gui) ``` -------------------------------- ### Build Native Executable Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Navigate to the src directory and use `go build` to create a native executable for the current platform. ```bash $ cd src $ go build . ``` -------------------------------- ### Quickly Create a File with Extension Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/README.md Provide the file name with its extension to 'qtcli new-file' to create the file without further prompts, if the extension is recognized. ```bash $ ./qtcli new-file mywidget.ui ``` -------------------------------- ### GET /v1/presets/:id Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Get details of a specific preset by its unique ID. ```APIDOC ## GET /v1/presets/:id ### Description Get details of a specific preset by ID. ### Method GET ### Endpoint /v1/presets/:id #### Path Parameters - **id** (string) - Required - The unique identifier of the preset. ### Request Example ```bash GET /v1/presets/2239089261 ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the preset. - **name** (string) - The name of the preset. - **meta** (object) - Metadata about the preset, including type, title, and description. ``` -------------------------------- ### Build Documentation with CMake on Windows Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/README.md Use this command to build the documentation on Windows using CMake. Ensure you replace placeholders with your actual Qt and project paths. Omit -DQT_BUILD_ONLINE_DOCS=ON for offline documentation. ```bash md vscodeext-docs cd vscodeext-docs <\path\to\Qt>\bin\qt-cmake -GNinja -DQT_BUILD_ONLINE_DOCS=ON ninja html_docs ``` ```bash C:\Qt\6.8.0\msvc2022_64\bin\qt-cmake.bat -GNinja C:\dev\vscodeext\doc ``` -------------------------------- ### Confirm Input Type Example Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Templates.md Example of a 'confirm' type prompt, asking a yes/no question. The default value is a boolean. ```yaml - id: useForm type: confirm question: "Use form?" default: true ``` -------------------------------- ### Create a New Qt Project Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/README.md Use the 'qtcli new ' command to create a new Qt project. You will be prompted to select a project preset. ```bash $ ./qtcli new myapp ? Pick a preset → [Default] @projects/cpp/console [Default] @projects/cpp/qtquick [Default] @projects/cpp/qwidget [Manually select features] Use the arrow keys to move, Enter to select. ``` -------------------------------- ### Text Input Type Example Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Templates.md Example of a 'text' type prompt, requesting string input from the user. A default string value can be provided. ```yaml - id: projectName type: text question: "Project name:" default: "MyProject" ``` -------------------------------- ### Build the Qt CLI Tool Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/README.md Navigate to the 'src' directory and run 'go build .' to compile the Qt CLI tool. The executable 'qtcli' will be generated in the current directory. ```bash cd src go build . ``` -------------------------------- ### Build Documentation with CMake on Linux Source: https://github.com/qt-labs/vscodeext/blob/dev/doc/README.md Use this command to build the documentation on Linux using CMake. Ensure you replace placeholders with your actual Qt and project paths. Omit -DQT_BUILD_ONLINE_DOCS=ON for offline documentation. ```bash mkdir -p doc/build cd doc/build /bin/qt-cmake -GNinja -DQT_BUILD_ONLINE_DOCS=ON .. ``` ```bash ninja html_docs ``` -------------------------------- ### Create New Project or File Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Use POST /v1/items to create a new project or file based on a specified preset. Include the desired name, working directory, and preset ID in the request body. ```bash POST /v1/items Content-Type: application/json { "name": "myapp", "workingDir": "/home/my_all_projects", "presetId": "3399596650" } ``` -------------------------------- ### Display Qt CLI Help Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/README.md Run 'qtcli' without any arguments to view the full list of available commands and global flags. Use '[command] --help' for specific command details. ```bash A CLI for creating Qt project and files Usage: qtcli [flags] qtcli [command] Available Commands: completion Generate the autocompletion script for the specified shell help Help about any command new Create a new project under the current directory new-file Create a new file in the current directory preset Inspect and manage presets test Test specific features Flags: -h, --help help for qtcli -v, --verbose Enable verbose output --version version for qtcli Use "qtcli [command] --help" for more information about a command. ``` -------------------------------- ### GET /v1/ready Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Health check endpoint to determine if the server is ready. ```APIDOC ## GET /v1/ready ### Description Health check endpoint. ### Method GET ### Endpoint /v1/ready ``` -------------------------------- ### Build qtcli for E2E Tests Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Build the `qtcli` executable and output it to the `tests/` directory using `go build -C ./src -o ../tests`. ```bash $ go build -C ./src -o ../tests ``` -------------------------------- ### GET /v1/presets Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Retrieve all presets. Supports filtering by type (project or file) and name. ```APIDOC ## GET /v1/presets ### Description Retrieve all presets or filter by type/name. ### Method GET ### Endpoint /v1/presets #### Query Parameters - **type** (string) - Optional - Filter by type: `project` or `file`. - **name** (string) - Optional - Filter by preset name. ### Request Example ```bash GET /v1/presets GET /v1/presets?type=project GET /v1/presets?name=@projects/cpp/console ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier of the preset. - **name** (string) - The name of the preset. - **meta** (object) - Metadata about the preset, including type, title, and description. ``` -------------------------------- ### Server Health Check Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Perform a health check on the server using the GET /v1/ready endpoint. ```bash GET /v1/ready ``` -------------------------------- ### Get Preset Details by ID Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Retrieve detailed information for a specific preset using its unique ID. ```bash GET /v1/presets/2239089261 ``` -------------------------------- ### Create Project Snapshot Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/Development.md Use `goreleaser --snapshot --clean --skip=publish` to build binaries and archives for the current project state without publishing. ```bash $ goreleaser --snapshot --clean --skip=publish ``` -------------------------------- ### Retrieve All Presets Source: https://github.com/qt-labs/vscodeext/blob/dev/qt-cli/docs/RestApi.md Use GET /v1/presets to retrieve all available presets. You can filter the results by type (project or file) or by name. ```bash GET /v1/presets GET /v1/presets?type=project GET /v1/presets?name=@projects/cpp/console ```