Compare commits

..

No commits in common. "3ce4cbfad71dd989777006e726bc7607f7c15bee" and "f7737ea00d6750028d385590d847859c83c40a4e" have entirely different histories.

4 changed files with 15 additions and 4 deletions

View File

@ -2,7 +2,7 @@
name = "ahab"
description = "docker cli wrapper"
readme = "README.md"
version = "0.3.1"
version = "0.3.0"
edition = "2021"
license = "MIT"
authors = ["Matej Janežič <janezic.mj@gmail.com>"]

View File

@ -21,5 +21,5 @@ Completion files are generated **during build process** in `target/*/build/*/out
Currently `ahab` respects three environment variables.
- `COMPOSE_FILE`: control which docker-compose file is used - defaults to `docker/local/docker-compose.yaml`
- `AHAB_DJANGO_CONTAINER`: control which compose service is used for sending django commands - defaults to `appserver`
- `AHAB_POSTGRES_CONTAINER`: control which compose service is used for sending postgres commands - defaults to `postgresdb`
- `AHAB_POSTGRES_CONATINER`: control which compose service is used for sending postgres commands - defaults to `postgresdb`
- `AHAB_POSTGRES_CONATINER`: control which compose service is used for sending django commands - defaults to `appserver`

View File

@ -7,6 +7,9 @@ fn main() -> Result<()> {
// always load dotenv on start
dotenvy::dotenv().ok();
// TODO: (matej) some prints about project
// eg: DJANGO_SETTINGS_MODULE for django projects, used docker-compose, etc.
let args = cli::Ahab::parse();
match args.command {

View File

@ -8,6 +8,13 @@ use anyhow::{anyhow, Result};
use crate::command_builder::CommandBuilder;
use crate::{create_file, safe_create_file};
fn get_django_settings_module() -> Result<String> {
let dsm = env::var("DJANGO_SETTINGS_MODULE")?;
eprintln!("USING: {dsm}");
Ok(dsm)
}
const DEBUG_TEMPLATE: &str = r#"from django.core.management.base import BaseCommand
class Command(BaseCommand):
@ -55,9 +62,10 @@ pub fn make_command(app: &PathBuf, name: &str) -> Result<()> {
}
pub fn manage(rest: &[String]) -> Result<()> {
let dsm = get_django_settings_module()?;
let container = env::var("AHAB_DJANGO_CONTAINER").unwrap_or("appserver".to_string());
let joined = rest.join(" ");
let command = format!("run --rm {container} python manage.py {joined}");
let command = format!("run --rm {container} python manage.py {joined} --settings={dsm}");
CommandBuilder::docker_compose().args(&command).exec()
}