Skip to content

Commit 6fc8aea

Browse files
committed
feat(cmd): Add command to sync current file.
1 parent 9d33bc1 commit 6fc8aea

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

src/langs/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
"protocol_onedrive_connect_fail": "Something went wrong from response from OneDrive. Maybe you rejected the auth?",
3535
"protocol_onedrive_connect_unknown": "Do not know how to deal with the callback: {{params}}",
3636

37-
"command_startsync": "start sync",
37+
"command_startsync": "start sync the folder",
38+
"command_startsync_file": "start sync current file",
3839
"command_forcesync": "Force full synchronization",
3940
"command_drynrun": "start sync (dry run only)",
4041
"command_exportsyncplans_json": "export sync plans in json format",

src/langs/zh_cn.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
"protocol_onedrive_connect_fail": "OneDrive 的回调请求有点异常。您是否拒绝了鉴权?",
3535
"protocol_onedrive_connect_unknown": "不知道如何处理此 callback:{{params}}",
3636

37-
"command_startsync": "开始同步(start sync)",
37+
"command_startsync": "开始同步文件夹",
38+
"command_startsync_file": "开始同步当前文件",
3839
"command_forcesync": "强制全量同步",
39-
"command_drynrun": "开始同步(空跑模式)(start sync (dry run only))",
40+
"command_drynrun": "开始同步(空跑模式)",
4041
"command_exportsyncplans_json": "导出同步计划为 json 格式(export sync plans in json format)",
4142
"command_exportsyncplans_table": "导出同步计划为表格格式(export sync plans in table format)",
4243
"command_exportlogsindb": "从数据库导出终端日志(export logs saved in db)",

src/langs/zh_tw.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,10 @@
3434
"protocol_onedrive_connect_fail": "OneDrive 的回撥請求有點異常。您是否拒絕了鑑權?",
3535
"protocol_onedrive_connect_unknown": "不知道如何處理此 callback:{{params}}",
3636

37-
"command_startsync": "開始同步(start sync)",
37+
"command_startsync": "开始同步文件夹",
38+
"command_startsync_file": "开始同步当前文件",
3839
"command_forcesync": "强制全量同步",
39-
"command_drynrun": "開始同步(空跑模式)(start sync (dry run only)",
40+
"command_drynrun": "开始同步(空跑模式)",
4041
"command_exportsyncplans_json": "匯出同步計劃為 json 格式(export sync plans in json format)",
4142
"command_exportsyncplans_table": "匯出同步計劃為表格格式(export sync plans in table format)",
4243
"command_exportlogsindb": "從資料庫匯出終端日誌(export logs saved in db)",

src/main.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,20 @@ export default class InvioPlugin extends Plugin {
831831
async () => this.syncRun("manual")
832832
);
833833

834+
this.addCommand({
835+
id: "start-sync-file",
836+
name: t("command_startsync_file"),
837+
icon: iconNameSyncLogo,
838+
callback: async () => {
839+
const activeFile = this.app.workspace.getActiveFile();
840+
log.info('active file: ', activeFile);
841+
if (activeFile instanceof TFile) {
842+
this.syncRun("manual", [activeFile.path]);
843+
} else {
844+
new Notice(`File not found`);
845+
}
846+
},
847+
});
834848
this.addCommand({
835849
id: "start-sync",
836850
name: t("command_startsync"),

0 commit comments

Comments
 (0)