Skip to content

Commit f83a8fe

Browse files
Add GitHub Codespaces support and usage guide (#11)
* Create devcontainer.json * Create postCreate.sh * feat(devcontainer): add Codespaces support and xlings bootstrap * 更新 README,新增 GitHub Codespaces 使用说明 * add codespace button to readme * run 'xlings checker' in post create --------- Co-authored-by: SPeak <[email protected]>
1 parent bdda880 commit f83a8fe

File tree

3 files changed

+51
-5
lines changed

3 files changed

+51
-5
lines changed

.devcontainer/devcontainer.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "mcpp-standard (Codespaces)",
3+
"image": "mcr.microsoft.com/devcontainers/cpp:ubuntu-24.04",
4+
"customizations": {
5+
"vscode": {
6+
"extensions": [
7+
"ms-vscode.cpptools",
8+
"twxs.cmake",
9+
"ms-vscode.cmake-tools",
10+
"formulahendry.code-runner"
11+
]
12+
}
13+
},
14+
"remoteUser": "vscode",
15+
"postCreateCommand": "/bin/bash .devcontainer/postCreate.sh"
16+
}

.devcontainer/postCreate.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# postCreate.sh
2+
#!/usr/bin/env bash
3+
set -euo pipefail
4+
5+
sudo apt-get update
6+
sudo apt-get install -y ncurses-bin libtinfo6 libncursesw6 curl ca-certificates git
7+
8+
if ! command -v xlings >/dev/null 2>&1; then
9+
curl -fsSL https://d2learn.org/xlings-install.sh | bash
10+
fi
11+
12+
source ~/.bashrc
13+
14+
xlings checker

README.md

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,20 @@ d2x update
6969

7070
## 快速开始
7171

72+
### 在线体验
73+
74+
> [**点击下面按钮**](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=Sunrisepeak/mcpp-standard) 即可在云端自动完成配置, 并进入练习代码检测模式
75+
76+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=Sunrisepeak/mcpp-standard)
77+
78+
> **提示:**
79+
>
80+
> * 更多项目使用细节, 可以参考 **本地练习环境快速搭建**[项目在线文档](https://sunrisepeak.github.io/mcpp-standard)
81+
> * 使用完毕请记得在 Codespaces 界面 Stop 容器,以节省额度。
82+
83+
84+
### 本地练习环境快速搭建
85+
7286
> 通过使用[xlings](https://github.com/d2learn/xlings)获取项目并运行**编译器驱动开发模式**(自动化检测)来进行代码练习
7387
>
7488
> - 环境搭建演示视频: [windows](https://www.bilibili.com/video/BV1L4KuzEEcE) - [linux](https://www.bilibili.com/video/BV182MtzPEiX?p=2) - [macos](https://www.bilibili.com/video/BV182MtzPEiX?p=2)
@@ -96,38 +110,40 @@ irm https://d2learn.org/xlings-install.ps1.txt | iex
96110

97111
</details>
98112

99-
### 获取项目
113+
#### 获取项目
100114

101115
> 下载项目到当前目录并自动配置本地环境
102116
103117
```bash
104118
xlings install d2x:mcpp-standard
105119
```
106120

107-
### 本地文档/电子书(可选)
121+
#### 本地文档/电子书(可选)
108122

109123
> 可以在项目目录执行`d2x book`命令, 打开本地文档(包含使用说明和电子书)
110124
111125
```bash
112126
d2x book
113127
```
114128

115-
### 练习代码自动检测
129+
#### 练习代码自动检测
116130

117131
> 在项目目录`mcpp-standard`运行checker命令, 进入练习代码自动检测程序
118132
119133
```bash
120134
xlings checker
121135
```
122136

123-
### 同步最新的练习代码
137+
#### 同步最新的练习代码
124138

125139
> 由于项目处于持续更新阶段, 可以使用下面的命令进行自动同步(如果同步失败, 可能需要手动用git进行更新项目代码)
126140
127141
```bash
128142
d2x update
129143
```
130144

145+
---
146+
131147
## 练习及视频解读列表
132148

133149
| c++标准 | 特性 | 标题 | 文档/练习代码/视频 | 备注 |
@@ -173,4 +189,4 @@ d2x update
173189
<img src="https://contrib.rocks/image?repo=Sunrisepeak/mcpp-standard" />
174190
</a>
175191

176-
<a href="https://hellogithub.com/repository/Sunrisepeak/mcpp-standard" target="_blank"><img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=7877f7cb12e940a5a432d49c19a360df&claim_uid=aNLTSv91Awj8ruX&theme=dark" alt="Featured|HelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>
192+
<a href="https://hellogithub.com/repository/Sunrisepeak/mcpp-standard" target="_blank"><img src="https://api.hellogithub.com/v1/widgets/recommend.svg?rid=7877f7cb12e940a5a432d49c19a360df&claim_uid=aNLTSv91Awj8ruX&theme=dark" alt="Featured|HelloGitHub" style="width: 250px; height: 54px;" width="250" height="54" /></a>

0 commit comments

Comments
 (0)