Skip to content

Commit bc9de65

Browse files
committed
README: moved usage to docs
1 parent 144ceb4 commit bc9de65

File tree

1 file changed

+0
-180
lines changed

1 file changed

+0
-180
lines changed

README.md

Lines changed: 0 additions & 180 deletions
Original file line numberDiff line numberDiff line change
@@ -88,186 +88,6 @@ Although building from source is not recommended, if you really want to do so, s
8888
* clang-format (for `poac fmt`)
8989
* clang-tidy (for `poac tidy`)
9090

91-
## Usage
92-
93-
### Start a new project with Poac
94-
95-
The `poac new` command lets you start a new Poac project:
96-
97-
```console
98-
you:~$ poac new hello_world
99-
Created binary (application) `hello_world` package
100-
```
101-
102-
> [!TIP]
103-
> If you want to integrate your existing project with Poac, use the `init` command:
104-
>
105-
> ```console
106-
> you:~/your-pj$ poac init
107-
> Created binary (application) `your-pj` package
108-
> ```
109-
>
110-
> This command just creates a `poac.toml` file not to break your project.
111-
112-
### Build the project
113-
114-
In most cases, you want to execute the generated binary as well as build the project.
115-
116-
```console
117-
you:~/hello_world$ poac run
118-
Compiling src/main.cc
119-
Linking hello_world
120-
Finished debug target(s) in 0.45386s
121-
Running poac-out/debug/hello_world
122-
Hello, world!
123-
```
124-
125-
If you just want to build it, run the `build` command:
126-
127-
```console
128-
you:~/hello_world$ poac build
129-
Finished debug target(s) in 0.00866317s
130-
```
131-
132-
Poac uses a cache since we executed the command with no changes.
133-
134-
> [!TIP]
135-
> To use a different compiler, you can export a `CXX` environmental variable:
136-
>
137-
> ```shell
138-
> export CXX=g++-13
139-
> ```
140-
141-
### Install dependencies
142-
143-
Like Cargo does, Poac installs dependencies at build time. Poac currently supports Git and system dependencies. You can use the `poac add` command to add dependencies to your project.
144-
145-
The `poac add` command accepts the following arguments:
146-
147-
`poac add <package names ....> --<options>`
148-
149-
Options:
150-
- `--sys`: Marks the packages as system dependency (requires the `--version` argument)
151-
- `--version`: Specify dependency version. Only used with system dependencies
152-
- `--rev`: Specify revision for git dependencies
153-
- `--tag`: Specify tag for git dependencies
154-
- `--branch`: Specify branch for git dependencies
155-
156-
Example
157-
```bash
158-
poac add libgit2 --sys --version "1.1.0"
159-
poac add "ToruNiina/toml11" --rev "846abd9a49082fe51440aa07005c360f13a67bbf"
160-
```
161-
162-
If `tag`, `branch`, or `rev` is unspecified for git dependencies, Poac will use the latest revision of the default branch. System dependency names must be acceptable by `pkg-config`. The version requirement syntax is specified in [src/VersionReq.hpp](https://github.com/poac-dev/poac/blob/main/src/VersionReq.hpp).
163-
164-
After adding dependencies, executing the `build` command will install the package and its dependencies.
165-
166-
```console
167-
you:~/hello_world$ poac build
168-
Downloaded ToruNiina/toml11 846abd9a49082fe51440aa07005c360f13a67bbf
169-
Compiling src/main.cc
170-
Linking hello_world
171-
Finished debug target(s) in 0.70s
172-
```
173-
174-
> [!WARNING]
175-
> Poac currently supports building a project with header-only dependencies.
176-
> Building with build-required dependencies will be soon supported.
177-
178-
### Unit tests
179-
180-
You can write unit tests in any source files within the `src` directory. Create a new file like:
181-
182-
`src/Lib.cc`
183-
184-
```cpp
185-
int add(int a, int b) {
186-
return a + b;
187-
}
188-
189-
#ifdef POAC_TEST
190-
191-
# include <cassert>
192-
193-
int main() {
194-
assert(add(1, 2) == 3); // ok
195-
assert(add(1, 2) == 4); // fail
196-
}
197-
198-
#endif
199-
```
200-
201-
Now, with the `test` command, you can run tests defined within `POAC_TEST`:
202-
203-
```console
204-
you:~/hello_world$ poac test
205-
Compiling src/Lib.cc
206-
Linking tests/test_Lib
207-
Testing Lib
208-
Assertion failed: (add(1, 2) == 4), function main, file Lib.cc, line 13.
209-
make: *** [test] Abort trap: 6
210-
```
211-
212-
Unit tests with the `POAC_TEST` macro are useful when testing private functions. Integration testing with the `tests` directory has not yet been implemented.
213-
214-
### Run linter
215-
216-
Linting source code is essential to protect its quality. Poac supports linting your project by the `lint` command:
217-
218-
```console
219-
you:~/hello_world$ poac lint
220-
Linting hello_world
221-
src/main.cc:0: No copyright message found. You should have a line: "Copyright [year] <Copyright Owner>" [legal/copyright] [5]
222-
Done processing src/main.cc
223-
Total errors found: 1
224-
Error: `cpplint` exited with status 1
225-
```
226-
227-
> [!TIP]
228-
> If you do not have `cpplint`, install it with the following command:
229-
>
230-
> ```bash
231-
> pip install cpplint
232-
> ```
233-
234-
The `lint` command works without configurations, and Poac would automatically opt out of unwanted lints by adjusting to each project.
235-
To customize the lint settings, try adding the `[lint.cpplint]` key in your `poac.toml` like [this](https://github.com/poac-dev/poac/blob/cc30b706fb49860903384df56d650a0955aca16c/poac.toml#L67-L83)
236-
or creating a [`CPPLINT.cfg`](https://github.com/poac-dev/poac/blob/5e7e3792e8818d165149214e94f30958fb0fef66/CPPLINT.cfg) file in the repository root.
237-
238-
### Run formatter
239-
240-
Poac also supports formatting your source code with `clang-format`. Ensure having installed `clang-format` before running this command.
241-
242-
```console
243-
you:~/hello_world$ poac fmt
244-
Formatting hello_world
245-
```
246-
247-
> [!NOTE]
248-
> This command automatically detects what files we need to format to avoid getting bothered by commands like:
249-
>
250-
> ```console
251-
> $ # We need to avoid the `build` dir and such dirs ...
252-
> $ clang-format ./src/*.cpp -i
253-
> $ clang-format ./include/**/*.hpp -i
254-
> $ clang-format ./tests/**/*.cpp -i
255-
> $ ...
256-
> ```
257-
258-
To customize the format settings, try creating a [`.clang-format`](/.clang-format) file to the repository root.
259-
260-
### Run `clang-tidy`
261-
262-
Poac also supports running `clang-tidy` on your source code. Ensure having installed `clang-tidy` before running this command.
263-
264-
```console
265-
you:~/hello_world$ poac tidy
266-
Running clang-tidy
267-
```
268-
269-
You can customize the tidy settings by creating a [`.clang-tidy`](/.clang-tidy) file to the repository root.
270-
27191
## Community
27292

27393
We use [GitHub Discussions](https://github.com/orgs/poac-dev/discussions).

0 commit comments

Comments
 (0)