()
| 87 | } |
| 88 | |
| 89 | func main() { |
| 90 | var ( |
| 91 | configFile string |
| 92 | dsn string |
| 93 | mountPoint string |
| 94 | password string |
| 95 | readOnly bool |
| 96 | ) |
| 97 | flag.StringVar(&configFile, "config", "~/.cql/config.yaml", "Config file path") |
| 98 | flag.StringVar(&mountPoint, "mount", "./", "Dir to mount") |
| 99 | flag.StringVar(&dsn, "dsn", "", "Database url") |
| 100 | flag.StringVar(&password, "password", "", "Master key password for covenantsql") |
| 101 | flag.BoolVar(&readOnly, "readonly", false, "Mount read only volume") |
| 102 | flag.Usage = usage |
| 103 | flag.Parse() |
| 104 | |
| 105 | log.SetLevel(log.InfoLevel) |
| 106 | |
| 107 | configFile = utils.HomeDirExpand(configFile) |
| 108 | |
| 109 | err := client.Init(configFile, []byte(password)) |
| 110 | if err != nil { |
| 111 | log.Fatal(err) |
| 112 | } |
| 113 | |
| 114 | cfg, err := client.ParseDSN(dsn) |
| 115 | if err != nil { |
| 116 | log.Fatal(err) |
| 117 | } |
| 118 | |
| 119 | db, err := sql.Open("covenantsql", cfg.FormatDSN()) |
| 120 | if err != nil { |
| 121 | log.Fatal(err) |
| 122 | } |
| 123 | |
| 124 | defer func() { _ = db.Close() }() |
| 125 | |
| 126 | if err := initSchema(db); err != nil { |
| 127 | log.Fatal(err) |
| 128 | } |
| 129 | |
| 130 | cfs := CFS{db} |
| 131 | opts := make([]fuse.MountOption, 0, 5) |
| 132 | opts = append(opts, fuse.FSName("CovenantFS")) |
| 133 | opts = append(opts, fuse.Subtype("CovenantFS")) |
| 134 | opts = append(opts, fuse.LocalVolume()) |
| 135 | opts = append(opts, fuse.VolumeName(cfg.DatabaseID)) |
| 136 | if readOnly { |
| 137 | opts = append(opts, fuse.ReadOnly()) |
| 138 | } |
| 139 | // Mount filesystem. |
| 140 | c, err := fuse.Mount( |
| 141 | mountPoint, |
| 142 | opts..., |
| 143 | ) |
| 144 | if err != nil { |
| 145 | log.Fatal(err) |
| 146 | } |
nothing calls this directly
no test coverage detected