Первая версия (CLI-only) #1

Merged
weirdcat merged 26 commits from develop into main 2025-11-27 13:09:27 +03:00
2 changed files with 78 additions and 24 deletions
Showing only changes of commit 419dc56f50 - Show all commits

View File

@@ -30,6 +30,7 @@ import (
type Config struct {
App AppConfig `mapstructure:"app"`
Screenshot ScreenshotConfig `mapstructure:"screenshot"`
Communication CommunicationConfig `mapstructure:"communication"`
Telemetry TelemetryConfig `mapstructure:"telemetry"`
Logging LoggingConfig `mapstructure:"logging"`
@@ -44,6 +45,13 @@ type AppConfig struct {
EnableCheckingUpdates bool `mapstructure:"enable_checking_updates"`
}
type ScreenshotConfig struct {
ScreenIndex int `mapstructure:"screen_index"`
Interval int `mapstructure:"interval"`
Directory string `mapstructure:"directory"`
BufferCount int `mapstructure:"buffer_count"`
}
type CommunicationConfig struct {
QrUrl string `mapstructure:"self_approve_url"`
QrQueryToken string `mapstructure:"qr_query_token"`
@@ -60,6 +68,10 @@ type LoggingConfig struct {
Output string `mapstructure:"output"`
}
func getTempDirectoryPath() string {
return os.TempDir()
}
func getDefaultConfig() Config {
return Config{
App: AppConfig{
@@ -70,6 +82,12 @@ func getDefaultConfig() Config {
Browser: "firefox",
EnableCheckingUpdates: true,
},
Screenshot: ScreenshotConfig{
ScreenIndex: 0,
Interval: 5,
Directory: getTempDirectoryPath(),
BufferCount: 5,
},
Logging: LoggingConfig{
Level: "info",
Output: "stdout",
@@ -117,6 +135,11 @@ func initializeViper(appName string) (*viper.Viper, string, error) {
v.SetDefault("app.browser", defaults.App.Browser)
v.SetDefault("app.enable_checking_updates", defaults.App.EnableCheckingUpdates)
v.SetDefault("screenshot.screen_index", defaults.Screenshot.ScreenIndex)
v.SetDefault("screenshot.interval", defaults.Screenshot.Interval)
v.SetDefault("screenshot.directory", defaults.Screenshot.Directory)
v.SetDefault("screenshot.buffer_count", defaults.Screenshot.BufferCount)
v.SetDefault("logging.level", defaults.Logging.Level)
v.SetDefault("logging.output", defaults.Logging.Output)
@@ -139,6 +162,11 @@ func (c *Config) Save() error {
v.Set("app.browser", c.App.Browser)
v.Set("app.enable_checking_updates", c.App.EnableCheckingUpdates)
v.Set("screenshot.screen_index", c.Screenshot.ScreenIndex)
v.Set("screenshot.interval", c.Screenshot.Interval)
v.Set("screenshot.directory", c.Screenshot.Directory)
v.Set("screenshot.buffer_count", c.Screenshot.BufferCount)
v.Set("logging.level", c.Logging.Level)
v.Set("logging.output", c.Logging.Output)

View File

@@ -0,0 +1,26 @@
// Copyright (c) 2025 Nikolai Papin
//
// This file is part of the Auto Attendance app that looks for
// self-attend QR-codes during lectures and opens their URLs in your
// browser.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
// the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
package screencapturer
type ScreenCapturer interface {
Start() error
Stop() error
Screenshot() (filepath string)
}